Files
chrysalis-mirror/.github/workflows/build.yml
Gergely Nagy fbda727f31 CI: Merge the snapshot & release workflows
Having two workflows that do mostly the same thing, and the major difference
between them is whether they create a new release, or reuse an existing one,
when they should be sharing the vast majority of code, is rather pointless, and
leads to bugs.

Bugs like forgetting to add the settings required for Windows code signing to
the release workflow.

With the workflows merged, we have a single build workflow to maintain, share
the vast majority of code between snapshot and production builds, and thus, we
can avoid such mishaps in the future.

It also makes the release process slightly more reliable, because the snapshot
and release builds will not trip over each other, as there will be only one.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
2022-07-29 12:42:17 +02:00

148 lines
4.5 KiB
YAML

name: Snapshot build & publish
on:
push:
branches:
- master
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install udev-dev
run: sudo apt update && sudo apt install libudev-dev
if: runner.os == 'Linux'
- name: Set up yarn network timeout
run: yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Yarn dependencies
env:
YARN_GPG: no
GITHUB_RUN_NUMBER: ${{ github.run_number }}
run: yarn
- name: Prepare for app notarization
if: startsWith(matrix.os, 'macos')
# Import Apple API key for app notarization on macOS
run: |
mkdir -p ~/private_keys/
echo '${{ secrets.api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
- name: Build Chrysalis
uses: samuelmeuli/action-electron-builder@v1
env:
YARN_GPG: no
API_KEY_ID: ${{ secrets.api_key_id }}
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
mac_certs: ${{ secrets.mac_certs }}
mac_certs_password: ${{ secrets.mac_certs_password }}
windows_certs: ${{ secrets.win_cert }}
windows_certs_password: ${{ secrets.win_cert_password }}
# We supply a build script name, so that we compile the source before
# trying to package them up. Without compiling them, we won't have the
# files to pack up.
build_script_name: build:${{ runner.os }}
# In this step, we only want to build Chrysalis, and never release. If
# we need to release, we do that in a separate step.
args: -p=never
release: false
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-artifact
path: |
dist/Chrysalis-*
dist/latest*.yml
!dist/*.blockmap
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Discover the version tag
id: version
run: echo ::set-output name=tag::$(tools/snapshot-tag)
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Delete the snapshot release
if: ${{ contains(steps.version.outputs.tag, 'snapshot') }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TAG: v${{steps.version.outputs.tag}}
shell: bash
run: |
gh release delete -y ${TAG} || true
git tag -d ${TAG} || true
git push origin :${TAG} || true
- name: Recreate the snapshot release
if: ${{ contains(steps.version.outputs.tag, 'snapshot') }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
VERSION: ${{steps.version.outputs.tag}}
shell: bash
run: |
gh release create -p -t "Chrysalis ${VERSION}" \
-n "Development snapshot." \
v${VERSION}
- name: Create the new release
if: ${{ !contains(steps.version.outputs.tag, 'snapshot') }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
VERSION: ${{ steps.version.outputs.tag }}
run: |
tools/release/news.sh >.news
gh release create -t "Chrysalis ${VERSION}" -F .news v${VERSION}
- name: Upload artifacts to the release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
TAG: v${{steps.version.outputs.tag}}
run: |
gh release upload ${TAG} \
artifacts/*/Chrysalis-* \
artifacts/*/latest*.yml