From ea895f7bfe61179254925d5d7333e1674534592e Mon Sep 17 00:00:00 2001 From: Louis Varin Date: Mon, 15 Jan 2024 11:17:38 -0500 Subject: [PATCH] feat: add a release workflow --- .github/workflows/release.yml | 122 ++++++++++++++++++++++++++++++++++ scripts/docker-build.sh | 11 +-- 2 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..db12c241 --- /dev/null +++ b/.github/workflows/release.yml @@ -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" + diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index 5bbee2c7..9fa2f589 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -1,7 +1,10 @@ #!/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 \ @@ -9,7 +12,7 @@ docker run --rm -ti \ -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