Add release workflow for cross-platform binary builds

Triggered on version tags (v*). Builds standalone binaries via PyInstaller
on Linux/macOS/Windows runners, wraps the Linux binary in a .deb via fpm,
and attaches all artifacts to a GitHub release.

https://claude.ai/code/session_01MqEqGhP1guGx5VuFsLaws2
This commit is contained in:
Claude 2026-05-08 16:17:43 +00:00
parent 24670a66dd
commit a1cc0874aa
No known key found for this signature in database

116
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,116 @@
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build — ${{ matrix.label }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
label: Linux amd64
binary_name: mdcms
artifact_name: mdcms-linux-amd64
make_deb: true
- os: macos-latest
label: macOS arm64
binary_name: mdcms
artifact_name: mdcms-macos-arm64
make_deb: false
- os: windows-latest
label: Windows amd64
binary_name: mdcms.exe
artifact_name: mdcms-windows-amd64
make_deb: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install pyinstaller click pyyaml
- name: Build binary
run: pyinstaller --onefile --name mdcms mdcms.py
- name: Rename binary (non-Windows)
if: matrix.os != 'windows-latest'
run: mv dist/mdcms dist/${{ matrix.artifact_name }}
- name: Rename binary (Windows)
if: matrix.os == 'windows-latest'
run: mv dist/mdcms.exe dist/${{ matrix.artifact_name }}.exe
- name: Build .deb (Linux only)
if: matrix.make_deb
run: |
VERSION=${GITHUB_REF_NAME#v}
gem install fpm --no-document
fpm \
-s dir -t deb \
-n mdcms \
-v "$VERSION" \
--description "MD-CMS companion CLI — manage and build MD-CMS sites" \
--url "https://github.com/kbenestad/mdcms" \
--maintainer "Kristian Benestad" \
--license "Apache-2.0" \
--architecture amd64 \
--category utils \
dist/mdcms-linux-amd64=/usr/local/bin/mdcms
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: |
dist/${{ matrix.artifact_name }}
dist/${{ matrix.artifact_name }}.exe
if-no-files-found: ignore
- name: Upload .deb artifact
if: matrix.make_deb
uses: actions/upload-artifact@v4
with:
name: deb-package
path: "*.deb"
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: false
- name: List artifacts
run: find artifacts -type f
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: mdcms ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: true
files: |
artifacts/mdcms-linux-amd64/mdcms-linux-amd64
artifacts/mdcms-macos-arm64/mdcms-macos-arm64
artifacts/mdcms-windows-amd64/mdcms-windows-amd64.exe
artifacts/deb-package/*.deb