Files
rsLXMF/.github/workflows/release.yml
T
2026-11-20 12:57:54 -07:00

191 lines
6.7 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag_name:
description: "Version tag (also used for untagged qualification)"
required: true
qualify_only:
description: "Build and verify archives without publishing or creating a tag"
type: boolean
default: true
required: true
permissions:
contents: read
actions: read
env:
SOURCE_REF: ${{ github.sha }}
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.ref_name }}
PACKAGE_ROOT: rsLXMF
LXMF_BINS: lxmd-rs
RSLXMF_RSRETICULUM_VERSION: 1.5.1
RSLXMF_RSRETICULUM_COMMIT: f6d0d698dd7e6edc180f9c3697ab1c873571f372
jobs:
verify:
name: Verify release source
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
ref: ${{ env.SOURCE_REF }}
path: rsLXMF
fetch-depth: 0
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
repository: ${{ github.repository_owner }}/rsReticulum
ref: ${{ env.RSLXMF_RSRETICULUM_COMMIT }}
path: rsReticulum
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.89.0
- name: Verify release source and dependency
working-directory: rsLXMF
shell: bash
env:
GH_TOKEN: ${{ github.token }}
QUALIFY_ONLY: ${{ github.event_name == 'workflow_dispatch' && inputs.qualify_only }}
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "${SOURCE_REF}"
gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/runs?head_sha=${SOURCE_REF}&event=push&per_page=100" \
--jq '.workflow_runs | any(.head_sha == env.SOURCE_REF and .conclusion == "success")' | grep -qx true
if [[ "${QUALIFY_ONLY}" == "true" ]]; then
python3 scripts/ci/check_source_release_contract.py --candidate-tag "${RELEASE_TAG}"
else
python3 scripts/ci/check_source_release_contract.py --release-tag "${RELEASE_TAG}"
fi
build:
name: Build ${{ matrix.artifact_suffix }}
needs: verify
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact_suffix: linux-x86_64
archive: tar.gz
- os: macos-latest
artifact_suffix: macos
archive: tar.gz
- os: windows-latest
artifact_suffix: windows-x86_64
archive: zip
runs-on: ${{ matrix.os }}
env:
ARCHIVE_NAME: rsLXMF-${{ github.event.inputs.tag_name || github.ref_name }}-${{ matrix.artifact_suffix }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
ref: ${{ env.SOURCE_REF }}
path: rsLXMF
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
repository: ${{ github.repository_owner }}/rsReticulum
ref: ${{ env.RSLXMF_RSRETICULUM_COMMIT }}
path: rsReticulum
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.89.0
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
workspaces: rsLXMF -> target
- name: Install system deps (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev libdbus-1-dev pkg-config
- name: Build release binaries
working-directory: rsLXMF
run: cargo build -p lxmf-tools --release --bins --locked
- name: Stage archive contents
shell: bash
working-directory: rsLXMF
run: |
set -euo pipefail
for bin in ${LXMF_BINS}; do
suffix=""
if [[ "${RUNNER_OS}" == "Windows" ]]; then suffix=".exe"; fi
"target/release/${bin}${suffix}" --version
done
mkdir -p "dist/${PACKAGE_ROOT}/bin"
for bin in ${LXMF_BINS}; do
if [[ "${RUNNER_OS}" == "Windows" ]]; then
cp "target/release/${bin}.exe" "dist/${PACKAGE_ROOT}/bin/${bin}.exe"
else
cp "target/release/${bin}" "dist/${PACKAGE_ROOT}/bin/${bin}"
fi
done
# Read blobs directly so Windows checkout line endings cannot alter the package.
for doc in README.md LICENSE CHANGELOG.md; do
git show "HEAD:${doc}" > "dist/${PACKAGE_ROOT}/${doc}"
done
- name: Create tar archive
if: runner.os != 'Windows'
shell: bash
working-directory: rsLXMF
run: tar -czf "${ARCHIVE_NAME}.tar.gz" -C dist "${PACKAGE_ROOT}"
- name: Create zip archive
if: runner.os == 'Windows'
shell: pwsh
working-directory: rsLXMF
run: Compress-Archive -Path "dist/${env:PACKAGE_ROOT}" -DestinationPath "${env:ARCHIVE_NAME}.zip" -Force
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ env.ARCHIVE_NAME }}
path: |
rsLXMF/*.tar.gz
rsLXMF/*.zip
if-no-files-found: error
package:
name: Verify release archives
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
ref: ${{ env.SOURCE_REF }}
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: rsLXMF-*
path: release-assets
merge-multiple: true
- name: Verify archive inventory and generate checksums
run: python3 scripts/ci/check_release_archives.py --tag "${RELEASE_TAG}" --directory release-assets
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: verified-release-assets
path: release-assets/*
if-no-files-found: error
publish:
name: Publish GitHub release
if: github.event_name == 'push' || !inputs.qualify_only
needs: package
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: verified-release-assets
path: release-assets
- uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3
with:
tag_name: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
body: ""
generate_release_notes: false
append_body: false
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
files: release-assets/*