From 54badc323d49f6f8c0d05d01f25f51d79a539b89 Mon Sep 17 00:00:00 2001 From: Soufiane Fariss Date: Mon, 14 Oct 2024 11:59:17 +0200 Subject: [PATCH] ci: add CHANGELOG.md for web releases --- .github/workflows/web-release.yml | 38 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/web-release.yml b/.github/workflows/web-release.yml index a0156657f..4dedff923 100644 --- a/.github/workflows/web-release.yml +++ b/.github/workflows/web-release.yml @@ -1,5 +1,4 @@ -name: create capa Explorer Web release - +name: create web release on: workflow_dispatch: inputs: @@ -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 @@ -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 "capa-dev@mandiant.com" - 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 "capa-dev@mandiant.com" + 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