lade 0.14.2

Automatically load secrets from your preferred vault as environment variables, and clear them once your shell command is over.
name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  check-bump:
    runs-on: ubuntu-24.04
    if: github.ref_type == 'tag'

    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ runner.os }}
      - name: Check version
        run: |
          VERSION=$(cargo run -- --version | cut -d' ' -f2)
          # shellcheck disable=SC2193
          if [[ "${{ github.ref_name }}" != "v$VERSION" ]]; then
            echo "Tag does not match code version v$VERSION, stopping."
            exit 1
          fi
          echo "Releasing v$VERSION"
      - uses: ncipollo/release-action@v1
        with:
          tag: ${{ github.ref_name }}
          makeLatest: true
          generateReleaseNotes: true

  crates:
    needs:
      - check-bump
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ runner.os }}
      - uses: katyo/publish-crates@v2
        with:
          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
          ignore-unpublished-changes: true

  binaries:
    needs:
      - check-bump
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: macos-15-intel
            target: x86_64-apple-darwin
            suffix: ""
            build_cmd: cargo
          - os: macos-15
            target: aarch64-apple-darwin
            suffix: ""
            build_cmd: cargo
          - os: ubuntu-24.04
            target: x86_64-unknown-linux-gnu
            suffix: ""
            build_cmd: cross
          - os: ubuntu-24.04
            target: x86_64-unknown-linux-musl
            suffix: ""
            build_cmd: cross
          - os: ubuntu-24.04
            target: aarch64-unknown-linux-gnu
            suffix: ""
            build_cmd: cross
          - os: ubuntu-24.04
            target: aarch64-unknown-linux-musl
            suffix: ""
            build_cmd: cross
          - os: windows-2025
            target: x86_64-pc-windows-msvc
            suffix: ".exe"
            build_cmd: cargo
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ runner.os }}
      - name: Install cross
        if: matrix.build_cmd == 'cross'
        run: curl -L https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz | tar xz -C ~/.cargo/bin
      - name: Build
        run: ${{ matrix.build_cmd }} build --locked --release --target ${{ matrix.target }}
      - name: Compress
        run: |
          mv "target/${{ matrix.target }}/release/lade${{ matrix.suffix }}" .
          tar czvf "lade-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" "lade${{ matrix.suffix }}"
      - name: Upload
        uses: svenstaro/upload-release-action@v2
        with:
          tag: ${{ github.ref }}
          file: "lade-${{ github.ref_name }}-${{ matrix.target }}.tar.gz"
          asset_name: "lade-${{ github.ref_name }}-${{ matrix.target }}.tar.gz"
          overwrite: false

  bump:
    needs:
      - crates
      - binaries
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ runner.os }}
      - name: Bump version
        id: bump
        run: |
          cargo install cargo-edit
          cargo set-version --bump beta
          echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r .packages[0].version)" >> "$GITHUB_OUTPUT"
      - uses: peter-evans/create-pull-request@v8
        with:
          branch: bump-${{ steps.bump.outputs.version }}
          delete-branch: true
          commit-message: "chore: prepare release ${{ steps.bump.outputs.version }}"
          title: "chore: prepare release ${{ steps.bump.outputs.version }}"
          body: "Automatic suggested bump"
          base: main