devsandbox 0.2.1

Manage devcontainer-style sandboxes on docker, podman, or Apple container — many throwaway instances per repo from one TOML config.
name: Release

on:
  push:
    tags: ["v*"]

permissions:
  contents: write

jobs:
  version:
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.check.outputs.version }}
    steps:
      - uses: actions/checkout@v4
      - id: check
        run: |
          version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
          if [ "v$version" != "$GITHUB_REF_NAME" ]; then
            echo "Tag $GITHUB_REF_NAME does not match Cargo.toml version $version" >&2
            exit 1
          fi
          echo "version=$version" >> "$GITHUB_OUTPUT"

  build:
    needs: version
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
          - target: aarch64-unknown-linux-musl
            os: ubuntu-24.04-arm
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - run: rustup target add ${{ matrix.target }}
      - if: contains(matrix.target, 'musl')
        run: sudo apt-get update && sudo apt-get install -y musl-tools
      - run: cargo build --release --target ${{ matrix.target }}
        env:
          # Static CRT on Windows so the binary doesn't need the VC++ redistributable
          RUSTFLAGS: ${{ contains(matrix.target, 'windows') && '-C target-feature=+crt-static' || '' }}
      - name: Package
        shell: bash
        run: |
          name="devsandbox-${{ needs.version.outputs.version }}-${{ matrix.target }}"
          mkdir dist
          case "${{ matrix.target }}" in
            *windows*)
              (cd "target/${{ matrix.target }}/release" && 7z a "$GITHUB_WORKSPACE/dist/$name.zip" devsandbox.exe)
              ;;
            *)
              tar czf "dist/$name.tar.gz" -C "target/${{ matrix.target }}/release" devsandbox
              ;;
          esac
      - uses: actions/upload-artifact@v4
        with:
          name: devsandbox-${{ matrix.target }}
          path: dist/*
          if-no-files-found: error

  release:
    needs: [version, build]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true
      - uses: softprops/action-gh-release@v2
        with:
          files: dist/*
      - uses: actions/checkout@v4
      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}