forked from mandiant/capa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: create capa Explorer Web release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version number for the release' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set release name | ||
id: set_release_name | ||
run: echo "RELEASE_NAME=capa-explorer-web-${{ 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" | ||
exit 1 | ||
fi | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
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: Run linting | ||
run: npm run lint | ||
working-directory: web/explorer | ||
|
||
- name: Check formatting | ||
run: npm run format:check | ||
working-directory: web/explorer | ||
|
||
- name: Run tests | ||
run: npm run test | ||
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 archive release to releases folder | ||
run: mv web/explorer/${{ env.RELEASE_NAME }}.zip 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 web/explorer/releases/${{ env.RELEASE_NAME }}.zip | ||
git commit -m "explorer web: add release ${{ env.RELEASE_NAME }}" | ||
git push | ||
- name: Remove older releases | ||
# keep only the latest 3 releases | ||
run: ls -t capa-explorer-web-*.zip | tail -n +4 | xargs -r rm -- | ||
working-directory: web/explorer/releases | ||
|
||
- name: Clean up | ||
if: always() | ||
run: rm -f ${{ env.RELEASE_NAME }}.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters