name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
publish-crate:
name: Publish crate to crates.io
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Check if crate version already exists
id: crate_check
shell: bash
run: |
CRATE_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)
CRATE_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
STATUS_CODE=$(curl -s -o /tmp/crate-version.json -w "%{http_code}" \
"https://crates.io/api/v1/crates/${CRATE_NAME}/${CRATE_VERSION}")
if [ "${STATUS_CODE}" = "200" ]; then
echo "published=true" >> "$GITHUB_OUTPUT"
echo "Version ${CRATE_NAME}@${CRATE_VERSION} already exists on crates.io. Skipping publish."
else
echo "published=false" >> "$GITHUB_OUTPUT"
echo "Version ${CRATE_NAME}@${CRATE_VERSION} not found on crates.io. Publishing."
fi
- name: Publish crate
if: steps.crate_check.outputs.published != 'true'
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
build-binaries:
name: Build binaries (${{ matrix.target }})
needs: publish-crate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: ""
- os: macos-15-intel
target: x86_64-apple-darwin
ext: ""
- os: macos-15
target: aarch64-apple-darwin
ext: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: ".exe"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust target
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target "${{ matrix.target }}"
- name: Pack binary
shell: bash
run: |
mkdir -p dist
cp "target/${{ matrix.target }}/release/ssmtui${{ matrix.ext }}" \
"dist/ssmtui-${{ github.ref_name }}-${{ matrix.target }}${{ matrix.ext }}"
# Create tar.gz for Homebrew (non-Windows only)
if [ "${{ matrix.ext }}" = "" ]; then
tar czf "dist/ssmtui-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" \
-C "target/${{ matrix.target }}/release" ssmtui
fi
- name: Upload binary to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*