Build & Release workflow (HemantKArya/Melodfy)
The Build & Release workflow from HemantKArya/Melodfy, explained and optimized by Latchkey.
CI health: D - needs work
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 & Release workflow from the HemantKArya/Melodfy 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 & Release"
on:
push:
branches: main
jobs:
builds:
name: Build & Release
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
# Setup Python
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11' # 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'
- run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install Pillow
pip install pyinstaller
# Build python script into a stand-alone exe
- name: Pyinstaller Build
run: |
pyinstaller Melodfy.spec
- name: Download 7zip
run: |
Invoke-WebRequest https://www.7-zip.org/a/7zr.exe -OutFile 7zr.exe
- name: Download ffmpeg-windows
run: |
Invoke-WebRequest https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.7z -OutFile ffmpeg-release-essentials.7z
./7zr.exe x ffmpeg-release-essentials.7z
$ffmpegFolder = Get-ChildItem -Directory -Name | Where-Object { $_ -like "ffmpeg-*-essentials_build" }
Move-Item "$ffmpegFolder/bin/ffmpeg.exe" "dist/Melodfy/_internal/"
- name: move model.onnx
run: |
Invoke-WebRequest https://huggingface.co/krystv/piano_inference_onnx/resolve/main/model.onnx -OutFile model.onnx
rm dist/Melodfy/_internal/models/model.onnx
mv model.onnx dist/Melodfy/_internal/models/
- name: Zip build
run: |
Compress-Archive -Path .\dist\Melodfy\ -DestinationPath .\dist\Melodfy_${{ runner.os }}_Build_${{ github.run_number }}.zip
# Uploads artifact
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Melodfy_${{ runner.os }}_Build_v${{ github.run_number }}
path: |
dist/Melodfy_${{ runner.os }}_Build_${{ github.run_number }}.zip
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/Melodfy_${{ runner.os }}_Build_${{ github.run_number }}.zip"
tag: v1.0.0+${{github.run_number}}
token: ${{secrets.SECRET_KEY}}
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: "Build & Release" on: push: branches: main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: builds: name: Build & Release runs-on: windows-latest steps: - name: Checkout Repository uses: actions/checkout@v3 # Setup Python - name: Setup Python uses: actions/setup-python@v4 with: cache: 'pip' python-version: '3.11' # 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' - run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install Pillow pip install pyinstaller # Build python script into a stand-alone exe - name: Pyinstaller Build run: | pyinstaller Melodfy.spec - name: Download 7zip run: | Invoke-WebRequest https://www.7-zip.org/a/7zr.exe -OutFile 7zr.exe - name: Download ffmpeg-windows run: | Invoke-WebRequest https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.7z -OutFile ffmpeg-release-essentials.7z ./7zr.exe x ffmpeg-release-essentials.7z $ffmpegFolder = Get-ChildItem -Directory -Name | Where-Object { $_ -like "ffmpeg-*-essentials_build" } Move-Item "$ffmpegFolder/bin/ffmpeg.exe" "dist/Melodfy/_internal/" - name: move model.onnx run: | Invoke-WebRequest https://huggingface.co/krystv/piano_inference_onnx/resolve/main/model.onnx -OutFile model.onnx rm dist/Melodfy/_internal/models/model.onnx mv model.onnx dist/Melodfy/_internal/models/ - name: Zip build run: | Compress-Archive -Path .\dist\Melodfy\ -DestinationPath .\dist\Melodfy_${{ runner.os }}_Build_${{ github.run_number }}.zip # Uploads artifact - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: Melodfy_${{ runner.os }}_Build_v${{ github.run_number }} path: | dist/Melodfy_${{ runner.os }}_Build_${{ github.run_number }}.zip - name: Create Release uses: ncipollo/release-action@v1 with: artifacts: "dist/Melodfy_${{ runner.os }}_Build_${{ github.run_number }}.zip" tag: v1.0.0+${{github.run_number}} token: ${{secrets.SECRET_KEY}}
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
1 third-party action is referenced by a movable tag. Pin it 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.