Build and Release workflow (Qliangw/notion_sync_data)
The Build and Release workflow from Qliangw/notion_sync_data, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Build and Release workflow from the Qliangw/notion_sync_data repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Build and Release
on:
push:
tags:
- '*'
release:
types: [prereleased]
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest] #
runs-on: ${{ matrix.os }}
steps:
- name: Check-out repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install Dependencies
run: |
pip install -r requirements.txt
- name: Build Executable
uses: Nuitka/Nuitka-Action@main
with:
script-name: run.py
onefile: true
include-plugin-directory: doc
include-plugin-files: README.md
- name: Upload Artifacts
id: artifacts
uses: actions/upload-artifact@v3
with:
name: notion_sync_${{ runner.os }}
path: |
build/*.exe
build/*.bin
build/*.app/**/*
release:
needs: build
runs-on: ubuntu-latest
#if: ${{ github.event_name == 'release'}}
permissions:
contents: write
steps:
- name: Download all from build
uses: actions/download-artifact@v3
id: download
- name: Display structure of downloaded files
run: |
echo "WORK_DIR"=${{steps.download.outputs.download-path}} >> $GITHUB_ENV
ls
- name: Organize files
run: |
wget https://raw.githubusercontent.com/Qliangw/notion_sync_data/main/doc/config.yaml.simple
mkdir -p ${{ env.WORK_DIR }}/notion_sync_Windows/doc
mkdir -p ${{ env.WORK_DIR }}/notion_sync_macOS/doc
mkdir -p ${{ env.WORK_DIR }}/notion_sync_Linux/doc
cp ./config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_Windows/doc/config.yaml
cp ./config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_macOS/doc/config.yaml
cp ./config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_Linux/doc/config.yaml
- name: Packages Files
run: |
cd ${{ env.WORK_DIR }}
zip -r notion_sync_Linux.zip notion_sync_Linux
zip -r notion_sync_macOS.zip notion_sync_macOS
zip -r notion_sync_Windows.zip notion_sync_Windows
- name: Create Release and Upload Release Asset
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release
draft: false
prerelease: false
files: |
${{ env.WORK_DIR }}/**.zip
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Build and Release on: push: tags: - '*' release: types: [prereleased] repository_dispatch: workflow_dispatch: inputs: ssh: description: 'SSH connection to Actions' required: false default: 'false' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] # runs-on: ${{ matrix.os }} steps: - name: Check-out repository uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified cache: 'pip' cache-dependency-path: | **/requirements*.txt - name: Install Dependencies run: | pip install -r requirements.txt - name: Build Executable uses: Nuitka/Nuitka-Action@main with: script-name: run.py onefile: true include-plugin-directory: doc include-plugin-files: README.md - name: Upload Artifacts id: artifacts uses: actions/upload-artifact@v3 with: name: notion_sync_${{ runner.os }} path: | build/*.exe build/*.bin build/*.app/**/* release: timeout-minutes: 30 needs: build runs-on: latchkey-small #if: ${{ github.event_name == 'release'}} permissions: contents: write steps: - name: Download all from build uses: actions/download-artifact@v3 id: download - name: Display structure of downloaded files run: | echo "WORK_DIR"=${{steps.download.outputs.download-path}} >> $GITHUB_ENV ls - name: Organize files run: | wget https://raw.githubusercontent.com/Qliangw/notion_sync_data/main/doc/config.yaml.simple mkdir -p ${{ env.WORK_DIR }}/notion_sync_Windows/doc mkdir -p ${{ env.WORK_DIR }}/notion_sync_macOS/doc mkdir -p ${{ env.WORK_DIR }}/notion_sync_Linux/doc cp ./config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_Windows/doc/config.yaml cp ./config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_macOS/doc/config.yaml cp ./config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_Linux/doc/config.yaml - name: Packages Files run: | cd ${{ env.WORK_DIR }} zip -r notion_sync_Linux.zip notion_sync_Linux zip -r notion_sync_macOS.zip notion_sync_macOS zip -r notion_sync_Windows.zip notion_sync_Windows - name: Create Release and Upload Release Asset uses: softprops/action-gh-release@v1 with: tag_name: ${{ github.ref }} name: Release draft: false prerelease: false files: | ${{ env.WORK_DIR }}/**.zip
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. - Cancel superseded runs when a branch or PR gets a newer push.
- 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:
- Dependency installs
- 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.