ebman 0.3.1

k9s-style TUI for AWS Elastic Beanstalk
name: release

on:
  push:
    tags:
      - 'v*'

# When a new tag like `v0.2.0` is pushed:
#   1. Build a release binary on each target platform.
#   2. Tarball it together with README + LICENSE files.
#   3. Attach the tarballs to a GitHub Release for the tag.
# Homebrew can then point at the macOS aarch64 / x86_64 tarballs by URL +
# SHA-256. The workflow uses softprops/action-gh-release which is the
# de-facto standard for this pattern and re-uses GITHUB_TOKEN.

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: short

jobs:
  build:
    name: build ${{ matrix.target }}
    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            runner: ubuntu-latest
            archive_ext: tar.gz
          - target: aarch64-apple-darwin
            runner: macos-latest
            archive_ext: tar.gz
          - target: x86_64-apple-darwin
            runner: macos-latest
            archive_ext: tar.gz
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: Swatinem/rust-cache@v2
      - name: Build release binary
        run: cargo build --locked --release --target ${{ matrix.target }}
      - name: Stage binary + docs
        run: |
          set -euo pipefail
          stage="ebman-${GITHUB_REF_NAME}-${{ matrix.target }}"
          mkdir "$stage"
          cp "target/${{ matrix.target }}/release/ebman" "$stage/"
          cp README.md LICENSE-MIT LICENSE-APACHE "$stage/"
          tar -czf "$stage.tar.gz" "$stage"
          shasum -a 256 "$stage.tar.gz" | tee "$stage.tar.gz.sha256"
      - name: Upload as workflow artifact
        uses: actions/upload-artifact@v4
        with:
          name: ebman-${{ matrix.target }}
          path: |
            ebman-*.tar.gz
            ebman-*.tar.gz.sha256

  publish:
    name: publish release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/download-artifact@v4
        with:
          path: dist
          pattern: ebman-*
          merge-multiple: true
      - name: Attach artefacts to release
        uses: softprops/action-gh-release@v2
        with:
          # GITHUB_REF_NAME is the tag, e.g. v0.2.0.
          tag_name: ${{ github.ref_name }}
          name: ebman ${{ github.ref_name }}
          files: |
            dist/ebman-*.tar.gz
            dist/ebman-*.tar.gz.sha256
          # Don't auto-publish a draft — the maintainer can flip the toggle
          # once they've sanity-checked the artefacts.
          draft: true
          generate_release_notes: true