stama 1.1.1

A terminal user interface for monitoring and managing slurm jobs.
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # Release body is taken from the matching section of CHANGELOG.md.
          changelog: CHANGELOG.md
          token: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    needs: create-release
    strategy:
      # Build every target even if one fails: a broken aarch64 build must
      # not cancel the x86_64 binaries most users need.
      fail-fast: false
      matrix:
        include:
          # We build on ubuntu-22.04 (not -latest) on purpose: the resulting
          # gnu binaries link against an older glibc, so they run on the aging
          # distros commonly found on HPC cluster login nodes.
          # The musl target is a fully static binary that works even on
          # CentOS7-era login nodes where the system glibc is too old.
          # (aarch64-musl is intentionally absent: it fails to link on the
          # arm runners and aarch64 login nodes are modern enough for gnu.)
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-22.04
          - target: x86_64-unknown-linux-musl
            os: ubuntu-22.04
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-22.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      # aarch64-unknown-linux-musl does not default to rust's self-contained
      # linking (unlike x86_64), so musl targets need the musl C toolchain.
      - name: Install musl toolchain
        if: contains(matrix.target, 'musl')
        run: sudo apt-get update -y && sudo apt-get install -y musl-tools
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: stama
          target: ${{ matrix.target }}
          tar: unix
          checksum: sha256
          token: ${{ secrets.GITHUB_TOKEN }}

  publish-crate:
    needs: upload-assets
    runs-on: ubuntu-latest
    # Uses crates.io Trusted Publishing (OIDC) - no long-lived API token needed.
    # One-time setup:
    #   1. On crates.io: stama -> Settings -> Trusted Publishing -> add a
    #      GitHub config with repository "Gordi42/stama", workflow
    #      "release.yml", and environment "release".
    #   2. In the GitHub repo settings, create an environment named "release".
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}