Files
2025-09-01 17:02:48 -05:00

115 lines
3.5 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build:
needs: create-release
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_name: kfmtbox-linux-x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
asset_name: kfmtbox-linux-x86_64-musl
- os: macos-latest
target: x86_64-apple-darwin
asset_name: kfmtbox-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
asset_name: kfmtbox-macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_name: kfmtbox-windows-x86_64.exe
- os: windows-latest
target: x86_64-pc-windows-gnu
asset_name: kfmtbox-windows-x86_64-gnu.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Strip binary (Unix)
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/kfmtbox
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: target/${{ matrix.target }}/release/kfmtbox${{ matrix.target == 'x86_64-pc-windows-msvc' && '.exe' || matrix.target == 'x86_64-pc-windows-gnu' && '.exe' || '' }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
publish-crate:
needs: create-release
runs-on: ubuntu-latest
if: github.repository_owner == 'koftwentytwo' # Only publish from the main repository
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
update-homebrew:
needs: [create-release, build]
runs-on: ubuntu-latest
if: github.repository_owner == 'koftwentytwo' # Only update from the main repository
steps:
- name: Checkout homebrew-core
uses: actions/checkout@v4
with:
repository: Homebrew/homebrew-core
token: ${{ secrets.HOMEBREW_CORE_TOKEN }}
path: homebrew-core
- name: Update formula
run: |
# This would typically be done via a PR to homebrew-core
# For now, we'll just prepare the formula
echo "Formula update would go here"
echo "See: https://docs.brew.sh/Adding-Software-to-Homebrew"