Skip to content

Release packages

Release packages #51

name: Release packages
on:
workflow_dispatch:
inputs:
tag:
description: "Git tag to release (e.g., v1.4.1). Leave empty or set to 'latest' to use the latest v* tag."
required: false
default: "latest"
prerelease:
description: "Mark as prerelease"
required: false
default: "false"
permissions:
contents: write
jobs:
build:
name: Build packages (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history and tags so we can resolve 'latest'
- name: Compute version/tag
id: meta
shell: bash
run: |
set -euo pipefail
INPUT_TAG="${{ github.event.inputs.tag }}"
if [[ -z "${INPUT_TAG}" || "${INPUT_TAG}" == "latest" ]]; then
# Find latest SemVer-ish tag starting with 'v'
TAG=$(git tag --list 'v*' | sort -V | tail -n1)
if [[ -z "$TAG" ]]; then
echo "::error::No tags found matching 'v*'. Push a tag like v1.4.1 or specify a tag manually.";
exit 1
fi
else
TAG="${INPUT_TAG}"
fi
# Validate tag exists
if ! git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "::error::Tag not found: $TAG";
git tag --list | sort -V | tail -n 20 | sed 's/^/hint: /'
exit 1
fi
CLEAN="${TAG#v}"
echo "version=$CLEAN" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Setup Go (for nfpm)
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install nfpm
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Prepare dist dir
run: mkdir -p dist
- name: Update pyproject.toml with release version
env:
VERSION: ${{ steps.meta.outputs.version }}
run: |
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
echo "Updated pyproject.toml version to $VERSION"
grep "^version = " pyproject.toml
- name: Build packages
env:
VERSION: ${{ steps.meta.outputs.version }}
ARCH: ${{ matrix.arch }}
run: |
nfpm pkg --packager deb -f packaging/nfpm.yaml --target dist/
nfpm pkg --packager rpm -f packaging/nfpm.yaml --target dist/
nfpm pkg --packager archlinux -f packaging/nfpm.yaml --target dist/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: voxd-${{ steps.meta.outputs.version }}-${{ matrix.arch }}
path: dist/*
outputs:
version: ${{ steps.meta.outputs.version }}
tag: ${{ steps.meta.outputs.tag }}
release:
name: Create GitHub Release and upload assets
runs-on: ubuntu-latest
needs: build
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Create/Update Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.build.outputs.tag }}
name: VOXD ${{ needs.build.outputs.tag }}
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
files: |
dist/**
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}