Files
matcha/.github/workflows/release.yml
T
chrnx d01be6e393
CI / check (pull_request) Successful in 40s
feat: rename crate to matcha-cli + two-forge CI/CD workflows
Crate renamed matcha->matcha-cli for crates.io (the name matcha is taken); binary stays matcha. Adds description/license/repository and CalVer prerelease version. New .github/workflows: ci (fmt+clippy+test), promote (main+tags -> GitHub), release (relocated from .gitea + crates.io publish on GitHub only). Cargo.lock regenerated; gate passes locally.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-18 13:58:18 -05:00

99 lines
3.4 KiB
YAML

name: Release
# On a version tag: build cross-platform binaries and attach them to the release (on
# whichever forge fired — the release API calls are portable). ADDITIONALLY, on GitHub
# only (production), publish the crate to crates.io.
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
# Gitea's delete-asset API differs from GitHub's (it requires the release id in the
# path), so softprops' delete-then-reupload 404s when re-releasing an existing tag.
# Delete the whole release first so every run's uploads are fresh. Portable: the
# get-by-tag + delete-by-id endpoints exist on both Gitea and GitHub, and deleting
# first is harmless on GitHub (softprops just recreates it).
prepare:
runs-on: ubuntu-latest
steps:
- name: Delete existing release for this tag
env:
GT_TOKEN: ${{ github.token }}
run: |
tag="$GITHUB_REF_NAME"
api="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY"
id=$(curl -sSL -H "Authorization: token $GT_TOKEN" "$api/releases/tags/$tag" \
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true)
if [ -n "${id:-}" ]; then
echo "deleting existing release id=$id for $tag"
curl -sS -X DELETE -H "Authorization: token $GT_TOKEN" "$api/releases/$id" || true
else
echo "no existing release for $tag — nothing to delete"
fi
build:
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-apple-darwin
os: macos-14
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Add target + musl tooling
run: |
rustup target add ${{ matrix.target }}
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then
sudo apt-get update && sudo apt-get install -y musl-tools
fi
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package
run: |
TAR="matcha-${{ matrix.target }}.tar.gz"
tar -czf "$TAR" -C "target/${{ matrix.target }}/release" matcha
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$TAR" > "$TAR.sha256"
else
shasum -a 256 "$TAR" > "$TAR.sha256"
fi
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: |
matcha-${{ matrix.target }}.tar.gz
matcha-${{ matrix.target }}.tar.gz.sha256
# crates.io = production only.
publish-crate:
if: ${{ github.server_url == 'https://github.com' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}
run: cargo publish --locked