wovensnake 0.3.6

A high-performance Python package manager built with Rust.
Documentation
name: Release & Publish

# ─── WHEN TO TRIGGER ──────────────────────────────────────────────────────────
# Only tag + release when Rust source code changes (src/, Cargo.toml).
#
# Versioning rules (SemVer):
#   PATCH  0.3.x → 0.3.x+1  bug fixes in src/
#   MINOR  0.3.x → 0.4.0    new features in src/
#   MAJOR  0.x   → 1.0.0    breaking API changes
#
# Changes to scripts/, README.md, CHANGELOG.md, .github/ (non-workflow)
# should be pushed to main WITHOUT a tag — they are served from the main
# branch URL and do not require new binaries.
#
# To release:
#   1. Bump version in Cargo.toml
#   2. Add entry to CHANGELOG.md
#   3. git tag -a vX.Y.Z -m "..." && git push origin vX.Y.Z
# ──────────────────────────────────────────────────────────────────────────────
on:
  push:
    tags:
      - "v*"       # push a tag ONLY when src/ or Cargo.toml changes (see policy above)
  workflow_dispatch:
    inputs:
      tag:
        description: "Tag to release (e.g. v0.4.0) — must already exist in the repo"
        required: true

permissions:
  contents: write

jobs:
  # --------------------------------------------------------------------------
  # 1. BUILD BINARIES & GITHUB RELEASE
  # --------------------------------------------------------------------------
  github-release:
    name: Build Release (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            artifact_name: woven
            asset_name: woven-linux-amd64
            target: x86_64-unknown-linux-musl
          - os: windows-latest
            artifact_name: woven.exe
            asset_name: woven-windows-amd64.exe
          - os: macos-latest
            artifact_name: woven
            asset_name: woven-macos-amd64
          - os: macos-14
            artifact_name: woven
            asset_name: woven-macos-arm64

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.inputs.tag || github.ref }}

      - name: Install Rust Toolchain
        uses: dtolnay/rust-toolchain@v1
        with:
          toolchain: stable
          targets: ${{ matrix.target }}

      - name: Install musl tools (Linux)
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: sudo apt-get install -y musl-tools

      - name: Build Release
        run: cargo build --release --verbose ${{ matrix.target && format('--target {0}', matrix.target) || '' }}
        shell: bash

      - name: Extract Changelog
        shell: bash
        run: |
          # Resolve version from tag push or manual dispatch input
          RAW_REF="${{ github.event.inputs.tag || github.ref }}"
          VERSION="${RAW_REF#refs/tags/v}"
          VERSION="${VERSION#v}"   # strip leading 'v' if workflow_dispatch passed 'v0.4.0'
          sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '1d;$d' > release_notes.md

      # Prepare asset name (Cross-platform way using bash which works on all runners)
      - name: Prepare Asset
        id: prep
        shell: bash
        run: |
          RELEASE_DIR="target/${{ matrix.target && format('{0}/release', matrix.target) || 'release' }}"
          mv "$RELEASE_DIR/${{ matrix.artifact_name }}" "$RELEASE_DIR/${{ matrix.asset_name }}"
          echo "asset_path=$RELEASE_DIR/${{ matrix.asset_name }}" >> "$GITHUB_OUTPUT"

      - name: Upload to GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ github.event.inputs.tag || github.ref_name }}
          files: ${{ steps.prep.outputs.asset_path }}
          body_path: release_notes.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  # --------------------------------------------------------------------------
  # 2. PUBLISH TO CRATES.IO
  # --------------------------------------------------------------------------
  crates-io-publish:
    name: Publish to Crates.io
    needs: github-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust Toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable

      - name: Publish to Crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish