Skip to content

Commit

Permalink
ci: add CHANGELOG.md for web releases
Browse files Browse the repository at this point in the history
  • Loading branch information
fariss committed Oct 14, 2024
1 parent 2e2e1bc commit 54badc3
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/web-release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: create capa Explorer Web release

name: create web release
on:
workflow_dispatch:
inputs:
Expand All @@ -19,12 +18,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set release name
run: echo "RELEASE_NAME=capa-explorer-web-${{ github.event.inputs.version }}-${GITHUB_SHA::7}" >> $GITHUB_ENV
run: echo "RELEASE_NAME=capa-explorer-web-v${{ github.event.inputs.version }}-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Check if release already exists
run: |
if ls web/explorer/releases/capa-explorer-web-${{ github.event.inputs.version }}-* 1> /dev/null 2>&1; then
echo "A release with version ${{ github.event.inputs.version }} already exists"
if ls web/explorer/releases/capa-explorer-web-v${{ github.event.inputs.version }}-* 1> /dev/null 2>&1; then
echo "::error:: A release with version ${{ github.event.inputs.version }} already exists"
exit 1
fi
Expand All @@ -50,18 +49,31 @@ jobs:
- name: Create releases directory
run: mkdir -vp web/explorer/releases

- name: Move archive release to releases folder
- name: Move release to releases folder
run: mv web/explorer/${{ env.RELEASE_NAME }}.zip web/explorer/releases

- name: Commit and push release
- name: Compute release SHA256 hash
run: |
git config --local user.email "[email protected]"
git config --local user.name "Capa Bot"
git add -f web/explorer/releases/${{ env.RELEASE_NAME }}.zip
git commit -m "explorer web: add release ${{ env.RELEASE_NAME }}"
git push
echo "RELEASE_SHA256=$(sha256sum web/explorer/releases/${{ env.RELEASE_NAME }}.zip | awk '{print $1}')" >> $GITHUB_ENV
- name: Update CHANGELOG.md
run: |
echo "## ${{ env.RELEASE_NAME }}" >> web/explorer/releases/CHANGELOG.md
echo "- Release Date: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> web/explorer/releases/CHANGELOG.md
echo "- SHA256: ${{ env.RELEASE_SHA256 }}" >> web/explorer/releases/CHANGELOG.md
echo "" >> web/explorer/releases/CHANGELOG.md
cat web/explorer/releases/CHANGELOG.md
- name: Remove older releases
# keep only the latest 3 releases
run: ls -t capa-explorer-web-*.zip | tail -n +4 | xargs -r rm --
run: ls -t capa-explorer-web-v*.zip | tail -n +4 | xargs -r rm --
working-directory: web/explorer/releases

- name: Commit and push release
run: |
git config --local user.email "[email protected]"
git config --local user.name "Capa Bot"
git add -f web/explorer/releases/${{ env.RELEASE_NAME }}.zip web/explorer/releases/CHANGELOG.md
git add -u web/explorer/releases/
git commit -m ":robot: explorer web: add release ${{ env.RELEASE_NAME }}"
git push

0 comments on commit 54badc3

Please sign in to comment.