Skip to content

Release

Release #22

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
dry_run:
description: "Build artifacts without creating a GitHub Release"
type: boolean
default: true
# Tag pushes (v*) and manual dispatch build Windows / Linux / macOS binaries.
# GitHub Releases are created only for version tags.
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
BINARY_NAME: nca
jobs:
ci-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config ripgrep
- name: Check formatting
run: cargo fmt --check --all
- name: Clippy
run: cargo clippy --workspace -- -D warnings
- name: Test
run: cargo test --workspace
build:
needs: ci-check
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install OpenSSL (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }} -p nca-cli
- name: Package
shell: bash
run: |
set -euo pipefail
BIN="${{ env.BINARY_NAME }}"
TARGET="${{ matrix.target }}"
ARCHIVE="${{ matrix.archive }}"
EXT=""
case "$TARGET" in
*windows*) EXT=".exe" ;;
esac
cd "target/${TARGET}/release"
if [[ ! -f "${BIN}${EXT}" ]]; then
echo "missing binary: ${BIN}${EXT}" >&2
ls -la
exit 1
fi
OUT="../../../${BIN}-${TARGET}.${ARCHIVE}"
if [[ "$ARCHIVE" == "zip" ]]; then
if command -v 7z >/dev/null 2>&1; then
7z a -tzip "$OUT" "${BIN}${EXT}"
else
# Windows runners ship bsdtar, which can write zip archives.
tar -a -c -f "$OUT" "${BIN}${EXT}"
fi
else
tar czf "$OUT" "${BIN}${EXT}"
fi
cd ../../..
ls -lh "${BIN}-${TARGET}.${ARCHIVE}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}-${{ matrix.target }}
path: ${{ env.BINARY_NAME }}-${{ matrix.target }}.${{ matrix.archive }}
if-no-files-found: error
release:
needs: build
if: always() && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-install-script:
needs: release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Update install script version
run: |
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' "s/^VERSION=.*/VERSION=\"${{ steps.version.outputs.version }}\"/" install.sh
else
sed -i "s/^VERSION=.*/VERSION=\"${{ steps.version.outputs.version }}\"/" install.sh
fi
- name: Commit updated install script
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add install.sh
git diff --staged --quiet || git commit -m "chore: bump install script to v${{ steps.version.outputs.version }}"
git push origin HEAD:main