From 4de544baa9c5b9ceb03fbc262347c704ab931531 Mon Sep 17 00:00:00 2001 From: Renato Rodrigues de Araujo Date: Mon, 9 Oct 2023 16:47:15 +0100 Subject: [PATCH] patch: Separate the workflows to generate release from tags --- .github/workflows/release.yaml | 44 ++++++++++------------------------ .github/workflows/tag.yaml | 41 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/tag.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 23bf1c5..75aad74 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,15 +2,19 @@ name: Release on: push: - branches: - - main + tags: + - "*" + +permissions: + contents: write jobs: - test: + release: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + fetch-depth: '0' - name: Set up JDK uses: actions/setup-java@v3 @@ -18,37 +22,15 @@ jobs: distribution: 'oracle' java-version: '21' - - name: Run Tests - run: ./gradlew test --no-daemon - - release: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.merge_commit_sha }} - fetch-depth: '0' - - - name: Bump version and push tag - id: version - uses: anothrNick/github-tag-action@1.64.0 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} - MAJOR_STRING_TOKEN: "major:" - MINOR_STRING_TOKEN: "minor:" - PATCH_STRING_TOKEN: "patch:" - - - name: Set project version for Gradle - run: echo "version='${{ steps.version.outputs.new_tag }}'" >> gradle.properties + - run: echo "version='${{ env.GITHUB_REF_NAME }}'" >> gradle.properties - - name: Build fat JAR + - name: Build Jar run: ./gradlew shadowJar --no-daemon - uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.RELEASE_TOKEN }}" - automatic_release_tag: ${{ steps.version.outputs.new_tag }} + automatic_release_tag: ${{ env.GITHUB_REF_NAME }} prerelease: false files: | - build/libs/uk-invitation-letter-${{ steps.version.outputs.new_tag }}.jar + build/libs/uk-invitation-letter-${{ env.GITHUB_REF_NAME }}.jar \ No newline at end of file diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml new file mode 100644 index 0000000..f6c833e --- /dev/null +++ b/.github/workflows/tag.yaml @@ -0,0 +1,41 @@ +name: Tag + +on: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'oracle' + java-version: '21' + + - name: Run Tests + run: ./gradlew test --no-daemon + + tag: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} + fetch-depth: '0' + + - name: Bump version and push tag + id: version + uses: anothrNick/github-tag-action@1.64.0 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + MAJOR_STRING_TOKEN: "major:" + MINOR_STRING_TOKEN: "minor:" + PATCH_STRING_TOKEN: "patch:" + WITH_V: true