diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..67783fe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +# Publish amendable binaries to GitHub Releases when an x.y.z tag is pushed. +# Set Cargo.toml version, commit on master, then: git tag X.Y.Z && git push origin X.Y.Z +name: Release + +permissions: + contents: read + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+-*' + pull_request: + paths: + - .github/workflows/release.yml + +env: + CARGO_INCREMENTAL: "0" + CARGO_TERM_COLOR: always + +jobs: + create-release: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Check Cargo.toml version matches tag + run: | + set -euo pipefail + tag="${GITHUB_REF_NAME}" + cargo_version="$(awk -F '"' '/^\[package\]/{p=1} p&&/^version =/{print $2; exit}' Cargo.toml)" + if [ "$tag" != "$cargo_version" ]; then + echo "Tag ${tag} does not match Cargo.toml version ${cargo_version}" >&2 + exit 1 + fi + - uses: taiki-e/create-gh-release-action@v1 + with: + branch: master + + upload-assets: + needs: create-release + if: ${{ !cancelled() && (needs.create-release.result == 'success' || needs.create-release.result == 'skipped') }} + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + - target: aarch64-apple-darwin + os: macos-latest + - target: x86_64-apple-darwin + os: macos-latest + - target: x86_64-pc-windows-msvc + os: windows-latest + runs-on: ${{ matrix.os }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/upload-rust-binary-action@v1 + with: + bin: amendable + target: ${{ matrix.target }} + tar: unix + zip: windows + checksum: sha256 + include: LICENSE,README.md + locked: true + dry-run: ${{ github.event_name != 'push' }} + dry-run-intended: ${{ github.event_name != 'push' }} diff --git a/AGENTS.md b/AGENTS.md index 5bc120f..3c57070 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,3 +33,13 @@ cargo test cargo fmt --check cargo clippy --all-targets -- -D warnings ``` + +## Releases + +Set `version` in `Cargo.toml`, commit on `master`, then push a matching `MAJOR.MINOR.PATCH` tag (`git tag 0.1.0 && git push origin 0.1.0`). GitHub Actions creates the GitHub Release and uploads `amendable` archives: + +- Linux x86_64 and ARM64 (static musl) +- macOS Apple Silicon and Intel +- Windows x86_64 + +The tag must point at a commit on `master` and must match `Cargo.toml`. Do not create the GitHub Release in the UI first; the workflow creates it from the tag. diff --git a/README.md b/README.md index 12df4ef..82574ee 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,25 @@ Command line client for [Amendable](https://amendable.io). The command name is `amendable`. +## Install + +Download the archive for your OS from [GitHub Releases](https://github.com/LaunchPlatform/amendable-cli/releases/latest). Extract `amendable` and put it on `PATH`. + +| Platform | Archive | +| --- | --- | +| Linux x86_64 | `amendable-x86_64-unknown-linux-musl.tar.gz` | +| Linux ARM64 | `amendable-aarch64-unknown-linux-musl.tar.gz` | +| macOS Apple Silicon | `amendable-aarch64-apple-darwin.tar.gz` | +| macOS Intel | `amendable-x86_64-apple-darwin.tar.gz` | +| Windows x86_64 | `amendable-x86_64-pc-windows-msvc.zip` | + +Linux archives are static musl builds. + ```bash -cargo install --git https://github.com/LaunchPlatform/amendable-cli --locked +curl -fsSL -o amendable.tar.gz \ + https://github.com/LaunchPlatform/amendable-cli/releases/latest/download/amendable-x86_64-unknown-linux-musl.tar.gz +tar -xzf amendable.tar.gz amendable +sudo mv amendable /usr/local/bin/amendable amendable login amendable repo create hello amendable repo clone hello @@ -11,7 +28,15 @@ amendable repo clone hello Talks to `https://api.amendable.io` by default. -## Install from a checkout +### Cargo + +Requires Rust 1.85+ ([rustup](https://rustup.rs/)). + +```bash +cargo install --git https://github.com/LaunchPlatform/amendable-cli --locked +``` + +From a checkout: ```bash git clone https://github.com/LaunchPlatform/amendable-cli.git @@ -20,8 +45,6 @@ cargo install --path . --locked amendable --help ``` -Requires Rust 1.85+ ([rustup](https://rustup.rs/)). - ## Config `~/.config/amendable/config.toml` (created on `login`, mode `0600`):