Skip to content

Commit

Permalink
Fix snapshot release deletion (#1068)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
fkleedorfer authored Dec 6, 2024
1 parent 442b7d8 commit a1c4a94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,43 @@ 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' }}
run: |
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
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit a1c4a94

Please sign in to comment.