From 5b0c4b81d6809b1cf3c7600fb34e4be31b5f3a14 Mon Sep 17 00:00:00 2001 From: Sergey Grigoriev Date: Thu, 9 Jan 2025 16:25:20 +0100 Subject: [PATCH] ci: workflow update (#330) --- .github/workflows/maven-build.yml | 20 +++++++++++--------- .github/workflows/pr.yml | 4 ++-- .github/workflows/release-please.yml | 3 ++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 203de009..94087d5b 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -6,6 +6,7 @@ on: pull_request: branches: [main] types: [opened, synchronize, reopened, ready_for_review] + workflow_dispatch: jobs: build: runs-on: ubuntu-latest @@ -20,11 +21,11 @@ jobs: MARKDOWN2HTML_MAVEN_PLUGIN_FAIL_ON_ERROR: true steps: - name: 📄 Checkout the repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - name: 🧱 Set up JDK and Maven - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4 + uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 with: distribution: adopt java-version: 17 @@ -37,7 +38,7 @@ jobs: run: echo "cache_key=${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}-${{ github.sha }}" >> $GITHUB_OUTPUT - name: 💾 Prepare cache using cache key id: prepare-cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | /home/runner/.m2 @@ -116,14 +117,14 @@ jobs: COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PASSPHRASE: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PASSPHRASE }} steps: - name: 🧱 Set up JDK and Maven - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4 + uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 with: distribution: adopt java-version: 17 gpg-private-key: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PRIVATE_KEY }} - name: 💾 Restore cache using cache key id: restore-cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | /home/runner/.m2 @@ -132,11 +133,11 @@ jobs: - name: 📦 Deploy artifacts to Maven Central run: mvn --batch-mode deploy -P gpg-sign -P nexus-staging - # Deploy release to GitHub Packages + # Deploy releases and snapshots for main branch to GitHub Packages deploy-github-packages: needs: build runs-on: ubuntu-latest - if: ${{ !endsWith(needs.build.outputs.project_version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }} + if: ${{ github.ref == 'refs/heads/main' }} permissions: contents: write packages: write @@ -146,13 +147,13 @@ jobs: GITHUB_TOKEN: ${{ github.token }} steps: - name: 🧱 Set up JDK and Maven - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4 + uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 with: distribution: adopt java-version: 17 - name: 💾 Restore cache using cache key id: restore-cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | /home/runner/.m2 @@ -161,5 +162,6 @@ jobs: - name: 📦 Deploy artifacts to GitHub Packages run: mvn --batch-mode -Dmaven.javadoc.skip=true -Dmaven.source.skip=true deploy -P deploy-github-packages - name: 📦 Upload assets to GitHub Release + if: ${{ !endsWith(needs.build.outputs.project_version, '-SNAPSHOT') }} run: |- gh release upload v${{ needs.build.outputs.project_version }} target/*-${{ needs.build.outputs.project_version }}.jar diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1a93cd65..bbba2b20 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,12 +10,12 @@ jobs: name: Check commit messages runs-on: ubuntu-latest steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: 3.x - run: pip install commitizen diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 57493be9..aec0a824 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -3,6 +3,7 @@ name: release-please on: push: branches: [main] + workflow_dispatch: permissions: contents: write pull-requests: write @@ -12,7 +13,7 @@ jobs: steps: - name: release-please id: release - uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4 + uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4.1.3 with: release-type: maven target-branch: main