From a1c4a94f188f1b5521f3b78580ac007d5987053c Mon Sep 17 00:00:00 2001 From: Florian Kleedorfer Date: Sat, 7 Dec 2024 00:34:03 +0100 Subject: [PATCH] Fix snapshot release deletion (#1068) * Improve github CI build and release actions With this commit, trying to delete the snapshot release when that release does not exist will not fail. Also, the format check of CHANGELOG.md is executed in each CI build - before the longer steps, so we fail fast. In addition to that, the creation of the release body now prevents bash command expansion in the changelog content. --- .github/workflows/maven.yml | 33 +++++++++++++++++++-------------- .github/workflows/release.yml | 6 ++++-- CHANGELOG.md | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 00e0d6ba..7890695a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -42,15 +42,28 @@ jobs: git config user.name ${{ github.actor }} git config user.email "<>" + # Read version changelog before anything else - if there is a formatting error + # in the changelog (which happens), we fail fast + # Do this even if we will not make the snapshot release, so the changelog is checked as part of a normal + # ci run. + - id: get-changelog + name: Get version changelog + uses: superfaceai/release-changelog-action@v1 + with: + path-to-changelog: CHANGELOG.md + version: ${{ inputs.release_version }} + operation: read + - name: Build with Maven run: mvn -Pzip install - # delete the snapshot release (the release action does not update the body, so we have to delete the whole thing) + # delete the snapshot release (the release action does not update the + # body, so we have to delete the whole thing) - name: Delete Snapshot Release if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release delete snapshot --cleanup-tag --yes + run: gh release delete snapshot --cleanup-tag --yes || echo "Error deleting snapshot release - continuing anyway" - name: change tag 'snapshot' to current commit if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }} @@ -58,22 +71,14 @@ jobs: git tag -f snapshot git push -f origin --tags - # Read version changelog - - id: get-changelog - name: Get version changelog - if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }} - uses: superfaceai/release-changelog-action@v1 - with: - path-to-changelog: CHANGELOG.md - version: ${{ inputs.release_version }} - operation: read - - name: Make Release Body if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }} run: | cat src/build/snapshot-release/release-body-header.md > target/release-body.md - echo "# Changes" >> target/release-body.md - echo "${{ steps.get-changelog.outputs.changelog }}" >> target/release-body.md + echo "# Changes" >> target/release-body.md + cat <<'EOF' >> target/release-body.md + ${{ steps.get-changelog.outputs.changelog }} + EOF cat src/build/snapshot-release/release-body-footer.md >> target/release-body.md # Make github release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6471eee4..57bb1fbf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -134,7 +134,9 @@ jobs: run: | cat src/build/release/release-body-header.md > target/release-body.md echo "# Changes" >> target/release-body.md - echo "${{ steps.get-changelog.outputs.changelog }}" >> target/release-body.md + cat <<'EOF' >> target/release-body.md + ${{ steps.get-changelog.outputs.changelog }} + EOF cat src/build/release/release-body-footer.md >> target/release-body.md - name: Release uses: softprops/action-gh-release@v2 @@ -172,7 +174,7 @@ jobs: - name: Delete Snapshot Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release delete snapshot --cleanup-tag --yes + run: gh release delete snapshot --cleanup-tag --yes || echo "Error deleting snapshot release - continuing anyway" # print the summary - name: Print summary diff --git a/CHANGELOG.md b/CHANGELOG.md index ee471899..6f85228c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ and this project is in the process of adopting [Semantic Versioning](https://sem - Make `qk:RotationalFrequency` exactMatch of `qk:RotationalVelocity`, remove broader qk - Make `qk:AngularFrequency` exactMatch of `qk:AngularVelocity`, remove broader qk -## Fixed +### Fixed - Rename incorrectly named Unit `unit:Ci` to `unit:CI` - Rename incorrectly named Unit `unit:Flight` to `unit:FLIGHT`