Skip to content

Commit

Permalink
feat: add a release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
louib-bitgo committed Jan 15, 2024
1 parent 5a7c0ce commit ea895f7
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 4 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: on_pr_edit
run-name: 'release: ${{ github.ref_name }}'

on:
workflow_dispatch:
pull_request:

# TODO I'll probably need permission to publish a new release.
permissions:
id-token: write
contents: read

env:
DMG_FILENAME: "Wallet Recovery Wizard.dmg"
EXE_FILENAME: "Wallet Recovery Wizard.exe"
DEB_FILENAME: "Wallet Recovery Wizard.deb"

jobs:
get-current-version:
name: Get the current version
runs-on: ubuntu-latest
outputs:
current_version: ${{ steps.get-current-version.outputs.current_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: get-current-version
run: |
latest_tag=$(git describe --abbrev=0 --tags | sed "s/v//g")
echo "current_version=$latest_tag" >> "$GITHUB_OUTPUT"
# TODO move this to the summary.
echo "Latest version is $latest_tag"
create-new-release-temp:
name: Get the current version
runs-on: ubuntu-latest
needs:
- get-current-version
steps:
- id: get-current-version
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/BitGo/wallet-recovery-wizard/releases \
-d '{"tag_name":"v9.9.9999","target_commitish":"master","name":"v9.9.9999","body":"Description of the release","draft":true,"generate_release_notes":true}'
exit 1
mac-build:
name: Create Mac release
runs-on: macos-latest
needs:
- get-current-version
- create-new-release-temp
env:
CURRENT_VERSION: "${{ needs.get-current-version.outputs.current_version }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'npm'
# TODO we should pin that version in the package-lock
- run: npm install dmg-license
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: "Wallet Recovery Wizard.dmg"
path: "release/${{ env.CURRENT_VERSION }}/Wallet Recovery Wizard-${{ env.CURRENT_VERSION }}.dmg"
if-no-files-found: "error"

windows-linux-build:
name: Create Windows and Linux release
runs-on: ubuntu-latest
needs:
- get-current-version
- create-new-release-temp
env:
CURRENT_VERSION: "${{ needs.get-current-version.outputs.current_version }}"
container:
# TODO sha-pin this image
image: electronuserland/builder:16-wine
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm run build -- -wl
- uses: actions/upload-artifact@v4
with:
name: "Wallet Recovery Wizard.exe"
path: "release/${{ env.CURRENT_VERSION }}/Wallet Recovery Wizard-Setup-${{ env.CURRENT_VERSION }}.exe"
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: "Wallet Recovery Wizard.deb"
path: "release/${{ env.CURRENT_VERSION }}/Wallet Recovery Wizard-Linux-${{ env.CURRENT_VERSION }}.deb"
if-no-files-found: "error"

create-new-release:
name: Create a new GitHub release
runs-on: ubuntu-latest
needs:
- mac-build
- windows-linux-build
env:
CURRENT_VERSION: "${{ needs.get-current-version.outputs.current_version }}"
container:
# TODO sha-pin this image
image: electronuserland/builder:16-wine
steps:
- uses: actions/download-artifact@v4
with:
# We don't want to download the artifacts to separate directories,
# we want to download them to the same directory instead.
merge-multiple: true
- run: |
sha256sum "${{ env.DEB_FILENAME }}" > "${{ env.DEB_FILENAME }}.sha256sum"
sha256sum "${{ env.EXE_FILENAME }}" > "${{ env.EXE_FILENAME }}.sha256sum"
sha256sum "${{ env.DMG_FILENAME }}" > "${{ env.DMG_FILENAME }}.sha256sum"
11 changes: 7 additions & 4 deletions scripts/docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/usr/bin/env bash

mkdir -p ~/.cache/electron-builder
mkdir -p ~/.cache/electron

docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v "${PWD}":/project \
-v "${PWD##*/}"-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:16-wine \
/bin/bash -c "npm install && npm run build -- -wl"
/bin/bash -c "ls -l && ls -l /project && echo \"$PWD\" && npm install && npm run build -- -wl"

npm i dmg-license && npm run build
npm uninstall dmg-license
# npm i dmg-license && npm run build
# npm uninstall dmg-license

0 comments on commit ea895f7

Please sign in to comment.