Skip to content

Commit

Permalink
Merge pull request #2455 from s-ff/web-add-releases-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fariss authored Oct 22, 2024
2 parents 23709c9 + 13b1e53 commit 7d8ee6a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 6 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/web-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: create web release
on:
workflow_dispatch:
inputs:
version:
description: 'Version number for the release (x.x.x)'
required: true
type: string

jobs:
run-tests:
uses: ./.github/workflows/web-tests.yml

build-and-release:
needs: run-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set release name
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-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
- name: Set up Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: 'web/explorer/package-lock.json'

- name: Install dependencies
run: npm ci
working-directory: web/explorer

- name: Build offline bundle
run: npm run build:bundle
working-directory: web/explorer

- name: Compress bundle
run: zip -r ${{ env.RELEASE_NAME }}.zip capa-explorer-web
working-directory: web/explorer

- name: Create releases directory
run: mkdir -vp web/explorer/releases

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

- name: Compute release SHA256 hash
run: |
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-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
13 changes: 7 additions & 6 deletions .github/workflows/web-tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Capa Explorer Web tests
name: capa Explorer Web tests

on:
pull_request:
branches: [ master ]
paths:
- 'web/explorer/**'
workflow_call: # this allows the workflow to be called by other workflows

jobs:
test:
Expand All @@ -23,20 +24,20 @@ jobs:
with:
node-version: 20
cache: 'npm'
cache-dependency-path: './web/explorer/package-lock.json'
cache-dependency-path: 'web/explorer/package-lock.json'

- name: Install dependencies
run: npm ci
working-directory: ./web/explorer
working-directory: web/explorer

- name: Lint
run: npm run lint
working-directory: ./web/explorer
working-directory: web/explorer

- name: Format
run: npm run format:check
working-directory: ./web/explorer
working-directory: web/explorer

- name: Run unit tests
run: npm run test
working-directory: ./web/explorer
working-directory: web/explorer
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Special thanks to our repeat and new contributors:
- CI: update Binary Ninja version to 4.1 and use Python 3.9 to test it #2211 @xusheng6
- CI: update tests.yml workflow to exclude web and documentation files #2263 @s-ff
- CI: update build.yml workflow to exclude web and documentation files #2270 @s-ff
- CI: add web releases workflow #2455 @s-ff

### Raw diffs

Expand Down
3 changes: 3 additions & 0 deletions web/explorer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# capa Explorer Web Releases
releases/

# Dependencies, build results, and other generated files
node_modules
.DS_Store
Expand Down

0 comments on commit 7d8ee6a

Please sign in to comment.