Build Windows workflow (Qliangw/notion_sync_data)
The Build Windows workflow from Qliangw/notion_sync_data, explained and optimized by Latchkey.
CI health: B - good
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Build Windows 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 Windows
on:
# push:
# tags:
# - '*'
repository_dispatch:
workflow_dispatch:
jobs:
build:
strategy:
matrix:
os: [windows-latest] # windows-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write
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
- 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}}" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "UPLOAD_FILE=${{steps.download.outputs.download-path}}\notion_sync_${{ runner.os }}.zip" | Out-File -FilePath $env:GITHUB_ENV -Append
ls
- name: Organize files
run: |
mkdir ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}/doc
cp ${{ env.WORK_DIR }}/doc/config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}/doc/config.yaml
- name: Packages Files
run: |
Compress-Archive -Path ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}/ ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}'.zip'
cp ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}.zip /
ls /**.zip
- name: Create Release and Upload Release Asset
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
draft: false
prerelease: false
files: |
**.zip
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Build Windows on: # push: # tags: # - '*' repository_dispatch: workflow_dispatch: jobs: build: timeout-minutes: 30 strategy: matrix: os: [windows-latest] # windows-latest runs-on: ${{ matrix.os }} permissions: contents: write 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 - 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}}" | Out-File -FilePath $env:GITHUB_ENV -Append echo "UPLOAD_FILE=${{steps.download.outputs.download-path}}\notion_sync_${{ runner.os }}.zip" | Out-File -FilePath $env:GITHUB_ENV -Append ls - name: Organize files run: | mkdir ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}/doc cp ${{ env.WORK_DIR }}/doc/config.yaml.simple ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}/doc/config.yaml - name: Packages Files run: | Compress-Archive -Path ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}/ ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}'.zip' cp ${{ env.WORK_DIR }}/notion_sync_${{ runner.os }}.zip / ls /**.zip - name: Create Release and Upload Release Asset uses: softprops/action-gh-release@v1 with: tag_name: ${{ github.ref }} name: Release ${{ github.ref }} draft: false prerelease: false files: | **.zip
What changed
- 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
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.