Skip to content

feat(release): add resilience infrastructure and cross-platform relea… #6

feat(release): add resilience infrastructure and cross-platform relea…

feat(release): add resilience infrastructure and cross-platform relea… #6

Workflow file for this run

name: Release
on:
push:
tags: ['v*']
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
# ============================================================
# Build Release Binaries
# ============================================================
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, cross: false }
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, cross: true }
- { os: macos-latest, target: x86_64-apple-darwin, cross: false }
- { os: macos-latest, target: aarch64-apple-darwin, cross: false }
- { os: windows-latest, target: x86_64-pc-windows-msvc, cross: false }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross
- name: Build
run: ${{ matrix.cross && 'cross' || 'cargo' }} build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../palrun-${{ matrix.target }}.tar.gz palrun pal
- name: Package (Windows)
if: runner.os == 'Windows'
run: Compress-Archive -Path target/${{ matrix.target }}/release/palrun.exe, target/${{ matrix.target }}/release/pal.exe -DestinationPath palrun-${{ matrix.target }}.zip
- uses: actions/upload-artifact@v4
with:
name: palrun-${{ matrix.target }}
path: palrun-${{ matrix.target }}.*
if-no-files-found: error
# ============================================================
# Generate SBOM
# ============================================================
sbom:
name: SBOM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Generate
run: |
cargo install cargo-sbom
cargo sbom --output-format cyclone_dx_json_1_4 > sbom.json
- uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.json
# ============================================================
# Create GitHub Release
# ============================================================
release:
name: Release
needs: [build, sbom]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract metadata
id: meta
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "prerelease=$([[ "$VERSION" == *-* ]] && echo true || echo false)" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare assets
run: |
mkdir release
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.json" \) -exec mv {} release/ \;
cd release && sha256sum * > SHA256SUMS.txt
- name: Generate changelog
run: |
cargo install git-cliff || true
git cliff --latest --strip header > CHANGELOG.md 2>/dev/null || echo "See commits for changes" > CHANGELOG.md
- uses: softprops/action-gh-release@v2
with:
files: release/*
body_path: CHANGELOG.md
prerelease: ${{ steps.meta.outputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================================
# Publish Packages
# ============================================================
publish-npm:
name: npm
needs: [release]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Publish
working-directory: npm
run: |
VERSION=${{ needs.release.outputs.version }}
npm version $VERSION --no-git-tag-version --allow-same-version
if [[ "$VERSION" == *-* ]]; then
TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
npm publish --access public --tag "$TAG"
else
npm publish --access public
fi
publish-crates:
name: crates.io
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
continue-on-error: true