Skip to content

Release 0.18.5: bump VERSION + metadata.json #35

Release 0.18.5: bump VERSION + metadata.json

Release 0.18.5: bump VERSION + metadata.json #35

Workflow file for this run

name: Build and Release Rust Router
# Builds prebuilt grid_router binaries for Linux x86_64, macOS arm64+x86_64,
# and Windows x86_64 whenever a version tag (vX.Y.Z) is pushed, packages
# them into KiCad PCM (Plugin and Content Manager) zips, and attaches
# everything to a GitHub Release.
#
# The Rust crate uses pyo3 abi3-py39, so one binary per platform works for
# every Python 3.9+ interpreter.
on:
push:
tags:
- 'v*'
workflow_dispatch: # allow manual runs from the Actions tab
permissions:
contents: write # needed to create/update the GitHub Release
jobs:
validate:
name: Validate version consistency
runs-on: ubuntu-latest
# Fail in seconds — before the ~10-min build matrix — if VERSION,
# metadata.json, and the pushed tag disagree (the half-bumped state that
# broke v0.17.0). Otherwise the mismatch only surfaces in the package job
# after every binary is built.
steps:
- uses: actions/checkout@v6
- name: VERSION <-> metadata.json (and tag) agree
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
python3 check_release_version.py --tag "${GITHUB_REF#refs/tags/}"
else
python3 check_release_version.py
fi
build:
name: Build ${{ matrix.target_name }}
needs: validate
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target_name: linux-x86_64
artifact_src: rust_router/target/release/libgrid_router.so
artifact_dst: grid_router-linux-x86_64.so
cargo_target: ''
extra_rustflags: ''
- os: macos-14
target_name: macos-arm64
artifact_src: rust_router/target/release/libgrid_router.dylib
artifact_dst: grid_router-macos-arm64.so
cargo_target: ''
# pyo3's extension-module needs these on macOS so Python symbols
# resolve at load time inside the interpreter instead of at link
# time. Locally pyo3-build-config sets this for you; in CI it
# doesn't always, so set it explicitly.
extra_rustflags: '-C link-arg=-undefined -C link-arg=dynamic_lookup'
# Cross-compile x86_64 macOS from the arm64 runner — macos-13
# runners are scarce and queue for 30+ min in the free tier.
- os: macos-14
target_name: macos-x86_64
artifact_src: rust_router/target/x86_64-apple-darwin/release/libgrid_router.dylib
artifact_dst: grid_router-macos-x86_64.so
cargo_target: 'x86_64-apple-darwin'
extra_rustflags: '-C link-arg=-undefined -C link-arg=dynamic_lookup'
- os: windows-latest
target_name: windows-x86_64
artifact_src: rust_router/target/release/grid_router.dll
artifact_dst: grid_router-windows-x86_64.pyd
cargo_target: ''
extra_rustflags: ''
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.cargo_target }}
- name: Cache cargo registry and target
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
rust_router/target
key: ${{ runner.os }}-${{ matrix.target_name }}-cargo-${{ hashFiles('rust_router/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target_name }}-cargo-
- name: Build release binary
shell: bash
env:
RUSTFLAGS: ${{ matrix.extra_rustflags }}
CARGO_TARGET: ${{ matrix.cargo_target }}
run: |
if [ -n "$CARGO_TARGET" ]; then
cargo build --release --target "$CARGO_TARGET" --manifest-path rust_router/Cargo.toml
else
cargo build --release --manifest-path rust_router/Cargo.toml
fi
- name: Stage artifact
shell: bash
run: cp "${{ matrix.artifact_src }}" "${{ matrix.artifact_dst }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_dst }}
path: ${{ matrix.artifact_dst }}
if-no-files-found: error
package:
name: Build PCM zips
needs: build
runs-on: ubuntu-latest
# We always package (even on manual workflow_dispatch) so PRs/branches
# can produce a downloadable zip for inspection. metadata.json is only
# committed/PR'd on tag pushes (see the release job below).
steps:
- uses: actions/checkout@v6
- name: Download all built binaries
uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: List downloaded binaries
run: ls -la artifacts
- name: Build PCM zip
run: python3 package_pcm.py --binary-dir artifacts
- name: Patch metadata.json with sha256 / sizes
run: |
python3 update_metadata.py \
--sidecar dist/KiCadRoutingTools-*.zip.meta.json \
--repo '${{ github.repository }}'
- name: List PCM artifacts
run: ls -la dist
- name: Upload PCM zips + metadata
uses: actions/upload-artifact@v7
with:
name: pcm-package
path: |
dist/*.zip
dist/*.meta.json
metadata.json
if-no-files-found: error
release:
name: Publish GitHub Release
needs: [build, package]
runs-on: ubuntu-latest
# Only publish a Release when a tag was pushed; manual runs just produce
# downloadable workflow artifacts.
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all built binaries
uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: List downloaded files
run: ls -la artifacts
- name: Create or update GitHub Release
uses: softprops/action-gh-release@v3
with:
# Attach: raw binaries, PCM zips, and the patched metadata.json
# (so a maintainer can grab the exact metadata.json that matches
# the published zips for submission to gitlab.com/kicad/addons).
# The package job uploaded the zips under dist/, and merge-multiple
# strips the artifact name but preserves the in-artifact path, so
# they land at artifacts/dist/.
files: |
artifacts/grid_router-*
artifacts/dist/KiCadRoutingTools-*.zip
artifacts/metadata.json
generate_release_notes: true
fail_on_unmatched_files: true