Nightly develop Binaries workflow (Superalgos/Superalgos)
The Nightly develop Binaries workflow from Superalgos/Superalgos, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Nightly develop Binaries workflow from the Superalgos/Superalgos repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Nightly develop Binaries
on:
schedule:
- cron: '20 3 * * *'
workflow_dispatch:
jobs:
create-release:
if: github.repository == 'superalgos/superalgos'
runs-on: ubuntu-latest
steps:
- name: Download a file
run: curl "https://raw.githubusercontent.com/${{ github.repository }}/develop/package.json" -o package.json
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- name: Get version
id: vars
run: echo "::set-output name=tag::$(node -p "require('./package.json').version")"
- name: Create nightly release
id: create_release
uses: viperproject/create-nightly-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.tag }}-${{ steps.date.outputs.date }}
release_name: Superalgos-Beta-v${{ steps.vars.outputs.tag }} Snapshot ${{ steps.date.outputs.date }}
keep_num: 5
keep_tags: false
build-release:
if: github.repository == 'superalgos/superalgos'
runs-on: ${{ matrix.os }}
needs: create-release
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- name: Check out Git repository
uses: actions/checkout@v2
with:
ref: develop
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 18
- name: Get version
id: vars
run: echo "::set-output name=tag::$(node -p "require('./package.json').version")"
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
args: "-c.extraMetadata.version=${{ steps.vars.outputs.tag }}-${{ steps.date.outputs.date }} -c build/electron-builder.json -p onTagOrDraft"
# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
# release: ${{ startsWith(github.ref, 'refs/tags/v') }}
release: true
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Nightly develop Binaries on: schedule: - cron: '20 3 * * *' workflow_dispatch: jobs: create-release: timeout-minutes: 30 if: github.repository == 'superalgos/superalgos' runs-on: latchkey-small steps: - name: Download a file run: curl "https://raw.githubusercontent.com/${{ github.repository }}/develop/package.json" -o package.json - name: Get current date id: date run: echo "::set-output name=date::$(date +'%Y%m%d')" - name: Get version id: vars run: echo "::set-output name=tag::$(node -p "require('./package.json').version")" - name: Create nightly release id: create_release uses: viperproject/create-nightly-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.vars.outputs.tag }}-${{ steps.date.outputs.date }} release_name: Superalgos-Beta-v${{ steps.vars.outputs.tag }} Snapshot ${{ steps.date.outputs.date }} keep_num: 5 keep_tags: false build-release: timeout-minutes: 30 if: github.repository == 'superalgos/superalgos' runs-on: ${{ matrix.os }} needs: create-release strategy: matrix: os: [windows-latest, macos-latest, ubuntu-latest] steps: - name: Get current date id: date run: echo "::set-output name=date::$(date +'%Y%m%d')" - name: Check out Git repository uses: actions/checkout@v2 with: ref: develop - name: Install Node.js, NPM and Yarn uses: actions/setup-node@v1 with: cache: 'npm' node-version: 18 - name: Get version id: vars run: echo "::set-output name=tag::$(node -p "require('./package.json').version")" - name: Build/release Electron app uses: samuelmeuli/action-electron-builder@v1 with: # GitHub token, automatically provided to the action # (No need to define this secret in the repo settings) github_token: ${{ secrets.github_token }} args: "-c.extraMetadata.version=${{ steps.vars.outputs.tag }}-${{ steps.date.outputs.date }} -c build/electron-builder.json -p onTagOrDraft" # If the commit is tagged with a version (e.g. "v1.0.0"), # release the app after building # release: ${{ startsWith(github.ref, 'refs/tags/v') }} release: true
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Network fetches
This workflow runs 2 jobs (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.