Files
2026-07-13 12:31:47 +08:00

162 lines
4.5 KiB
YAML

name: release
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
tag:
required: true
type: string
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: ${{ matrix.artifact }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# ----- Linux (glibc) -----
- artifact: fselect-x86_64-linux
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: true
fmt: gz
- artifact: fselect-aarch64-linux
target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
fmt: gz
# ----- Linux (musl, fully static) -----
- artifact: fselect-x86_64-linux-musl
target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true
fmt: gz
- artifact: fselect-aarch64-linux-musl
target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
fmt: gz
# ----- Windows -----
- artifact: fselect-x86_64-win
target: x86_64-pc-windows-msvc
os: windows-latest
cross: false
fmt: zip
# ----- macOS -----
- artifact: fselect-x86_64-mac
target: x86_64-apple-darwin
os: macos-13 # Intel runner
cross: false
fmt: gz
- artifact: fselect-aarch64-mac
target: aarch64-apple-darwin
os: macos-latest # Apple Silicon runner
cross: false
fmt: gz
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Build
shell: bash
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --locked --features git,git2/vendored-libgit2 --target ${{ matrix.target }}
else
cargo build --release --locked --features git,git2/vendored-libgit2 --target ${{ matrix.target }}
fi
- name: Package
shell: bash
run: |
if [ "${{ matrix.fmt }}" = "zip" ]; then
7z a "${{ matrix.artifact }}.zip" "./target/${{ matrix.target }}/release/fselect.exe"
else
gzip -c "./target/${{ matrix.target }}/release/fselect" > "${{ matrix.artifact }}.gz"
fi
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: ${{ matrix.artifact }}.${{ matrix.fmt }}
deb-package:
name: deb (x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
uses: taiki-e/install-action@v2
with:
tool: cargo-deb
- name: Build .deb package
run: cargo deb --features git,git2/vendored-libgit2 --output target/debian/
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: target/debian/*.deb
# Fedora/RHEL/openSUSE .rpm package (x86_64): fselect-<version>-1.x86_64.rpm
rpm-package:
name: rpm (x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-generate-rpm
run: cargo install cargo-generate-rpm --locked
- name: Build release binary
run: cargo build --release --locked --features git,git2/vendored-libgit2
- name: Strip binary
run: strip -s target/release/fselect
- name: Build .rpm package
run: cargo generate-rpm
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: target/generate-rpm/*.rpm