diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2bf2a63..7197289d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,12 +115,22 @@ jobs: - name: Build run: ./gradlew assemble + - name: Get tag + id: get_tag + run: | + if git describe --tags --abbrev=0 --exact-match >/dev/null; then + echo "tag=$(git describe --tags --abbrev=0 --exact-match)" >> $GITHUB_OUTPUT + else + echo "skip=true" >> $GITHUB_OUTPUT + fi + if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' + - name: Assemble release run: ./gradlew assembleRelease env: GPG_KEY_RING: ${{ secrets.GPG_KEY_RING }} # Run `gpg --export-secret-keys "" | base64` to get this GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} - if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.get_tag.outputs.skip != 'true' - name: Publish release run: ./gradlew publishRelease @@ -129,12 +139,7 @@ jobs: OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} GPG_KEY_RING: ${{ secrets.GPG_KEY_RING }} # Run `gpg --export-secret-keys "" | base64` to get this GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} - if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' - - - name: Get tag - id: get_tag - run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT - if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.get_tag.outputs.skip != 'true' - name: Add artifacts to GitHub release uses: softprops/action-gh-release@v2.0.8 @@ -145,4 +150,4 @@ jobs: draft: true # Update draft release with matching tag, if there is one. env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' + if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.get_tag.outputs.skip != 'true'