mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-06 08:18:58 +00:00
Add prerelease-aware release automation and keep default install and upgrade paths pinned to the latest stable tag unless an explicit prerelease version is requested.
132 lines
4.2 KiB
YAML
132 lines
4.2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
SEGMENT_BASE_URL: ${{ vars.SEGMENT_BASE_URL }}
|
|
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
|
|
|
|
jobs:
|
|
compile:
|
|
name: Compile (${{ matrix.target }})
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
runner: macos-15
|
|
- target: x86_64-unknown-linux-gnu
|
|
runner: ubuntu-latest
|
|
- target: aarch64-unknown-linux-gnu
|
|
runner: ubuntu-22.04-arm
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Rust
|
|
run: |
|
|
rustup toolchain install stable --profile minimal --no-self-update
|
|
rustup default stable
|
|
rustup target add ${{ matrix.target }}
|
|
|
|
- name: Build
|
|
run: cargo build --target ${{ matrix.target }} --release
|
|
|
|
- name: Test
|
|
run: cargo test --target ${{ matrix.target }} --release
|
|
|
|
- name: Package
|
|
run: |
|
|
mkdir fabro-${{ matrix.target }}
|
|
cp target/${{ matrix.target }}/release/fabro fabro-${{ matrix.target }}/
|
|
tar czf fabro-${{ matrix.target }}.tar.gz fabro-${{ matrix.target }}
|
|
shasum -a 256 fabro-${{ matrix.target }}.tar.gz > fabro-${{ matrix.target }}.tar.gz.sha256
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: artifacts-fabro-${{ matrix.target }}
|
|
path: |
|
|
fabro-${{ matrix.target }}.tar.gz
|
|
fabro-${{ matrix.target }}.tar.gz.sha256
|
|
|
|
release:
|
|
name: Release
|
|
needs: compile
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
with:
|
|
path: target/distrib
|
|
pattern: artifacts-fabro-*
|
|
merge-multiple: true
|
|
|
|
- name: Create GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
TAG_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
PRERELEASE_FLAG=""
|
|
if [[ "$TAG_NAME" == *-* ]]; then
|
|
PRERELEASE_FLAG="--prerelease"
|
|
fi
|
|
gh release create "$TAG_NAME" target/distrib/* --generate-notes $PRERELEASE_FLAG
|
|
|
|
update-homebrew:
|
|
name: Update Homebrew Formula
|
|
needs: release
|
|
if: ${{ !contains(github.ref_name, '-') }}
|
|
runs-on: ubuntu-latest
|
|
environment: release
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
with:
|
|
path: target/distrib
|
|
pattern: artifacts-fabro-*
|
|
merge-multiple: true
|
|
|
|
- name: Generate and push formula
|
|
env:
|
|
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
TAG_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
VERSION="${TAG_NAME#v}"
|
|
|
|
SHA_AARCH64_DARWIN=$(awk '{print $1}' target/distrib/fabro-aarch64-apple-darwin.tar.gz.sha256)
|
|
SHA_X86_64_LINUX=$(awk '{print $1}' target/distrib/fabro-x86_64-unknown-linux-gnu.tar.gz.sha256)
|
|
SHA_AARCH64_LINUX=$(awk '{print $1}' target/distrib/fabro-aarch64-unknown-linux-gnu.tar.gz.sha256)
|
|
|
|
sed \
|
|
-e "s/{{VERSION}}/$VERSION/g" \
|
|
-e "s/{{SHA_AARCH64_DARWIN}}/$SHA_AARCH64_DARWIN/g" \
|
|
-e "s/{{SHA_X86_64_LINUX}}/$SHA_X86_64_LINUX/g" \
|
|
-e "s/{{SHA_AARCH64_LINUX}}/$SHA_AARCH64_LINUX/g" \
|
|
installer/fabro.rb.template > fabro.rb
|
|
|
|
git clone https://x-access-token:${GH_TOKEN}@github.com/fabro-sh/homebrew-tap.git tap
|
|
cp fabro.rb tap/Formula/fabro.rb
|
|
cd tap
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add Formula/fabro.rb
|
|
git diff --cached --quiet || (git commit -m "Update fabro to ${TAG_NAME}" && git push)
|