JAVA_CI_DEPLOY #1277
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ansible managed | |
name: JAVA_CI_DEPLOY | |
on: | |
workflow_dispatch: | |
# branches: ['master'] | |
schedule: | |
- cron: "0 5 * * *" | |
env: | |
SPRING_PROFILE: ci | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'adopt' | |
server-id: ossrh | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_TOKEN | |
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} # Value of the GPG private key to import | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Maven compile and update dependencies | |
run: | | |
./mvnw -B -q -N io.takari:maven:wrapper | |
./mvnw -B -q versions:update-parent -DgenerateBackupPoms=false | |
./mvnw -B -q versions:update-properties -DgenerateBackupPoms=false | |
./mvnw -B -q dependency:resolve -Dmaven.test.skip=true -P=tag,release | |
./mvnw -B -q dependency:resolve-plugins -Dmaven.test.skip=true -P=tag,release | |
./mvnw -B -q clean verify -Dmaven.test.skip=true | |
- name: Run tests | |
run: ./mvnw -B clean verify | |
- name: Publish code quality | |
uses: paambaati/codeclimate-action@v3.0.0 | |
env: | |
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} | |
JACOCO_SOURCE_PATH: "${{github.workspace}}/src/main/java" | |
with: | |
coverageLocations: ${{github.workspace}}/target/site/jacoco/jacoco.xml:jacoco | |
- name: Remove code cov files | |
run: | | |
rm -rf coverage* &>/dev/null || true | |
rm -rf codeclimate* &>/dev/null || true | |
rm -rf ./*reporter* &>/dev/null || true | |
rm -rf public-key.asc &>/dev/null || true | |
git checkout src/test/resources/diagram_example.svg &>/dev/null || true | |
- name: Tag and Push | |
run: | | |
wget -nc https://raw.githubusercontent.com/YunaBraska/YunaBraska/main/.github/scripts/versions.sh -P target/pipeline_scripts | |
wget -nc https://raw.githubusercontent.com/YunaBraska/YunaBraska/main/.github/scripts/push_changes.sh -P target/pipeline_scripts | |
wget -nc https://raw.githubusercontent.com/YunaBraska/YunaBraska/main/.github/scripts/increment_version.sh -P target/pipeline_scripts | |
chmod +x target/pipeline_scripts/versions.sh target/pipeline_scripts/push_changes.sh target/pipeline_scripts/increment_version.sh | |
target/pipeline_scripts/push_changes.sh "https://x-access-token:${{ secrets.CI_TOKEN }}@github.com/${{ github.repository }}" | |
rm -rf target/pipeline_scripts | |
- name: "Check if branch exists" | |
run: | | |
git fetch origin release:release &>/dev/null || true | |
if git rev-parse --verify "release" &>/dev/null; then echo "::set-env name=HAS_RELEASE_BRANCH::true"; fi | |
- name: Publish package | |
if: env.HAS_RELEASE_BRANCH == 'true' | |
run: mvn -B clean deploy -P release -Dmaven.test.skip=true -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSH_USER }} | |
OSSRH_TOKEN: ${{ secrets.OSSH_PASS }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: "[Release] Get latest tag" | |
id: latest_tag | |
run: | | |
git fetch --all --tags | |
echo "::set-output name=name::$(git tag --sort=-creatordate | head -1)" | |
- name: "[Release] Get second latest tag" | |
id: second_latest_tag | |
run: | | |
git fetch --all --tags | |
echo "::set-output name=name::$(git tag --sort=-creatordate | head -2 | tail -1)" | |
- name: "[Release] Get changelog" | |
id: changelog | |
run: | | |
mkdir -p target | |
git log --pretty=format:'- %s%n' ${{ steps.second_latest_tag.outputs.name }}..${{ steps.latest_tag.outputs.name }} > target/release.log | |
echo "::set-output name=changelog::$(echo $(git log --pretty=format:'- %s\n' ${{ steps.second_latest_tag.outputs.name }}..${{ steps.latest_tag.outputs.name }}))" | |
- name: "[Release] create" | |
if: env.HAS_RELEASE_BRANCH == 'true' | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.latest_tag.outputs.name }} | |
artifacts: "target/*.jar,build/*.jar" | |
generateReleaseNotes: true | |
bodyFile: target/release.log | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Remove release branch" | |
run: | | |
git push --delete origin release &>/dev/null || true |