akv-cli 0.5.1

The Azure Key Vault CLI can be used to read secrets, pass them securely to other commands, or inject them into configuration files.
Documentation
name: release

on:
  push:
    tags:
    - "v*"

permissions:
  attestations: write
  contents: write
  id-token: write

defaults:
  run:
    shell: bash

env:
  CARGO_INCREMENTAL: 0
  RUSTFLAGS: -Dwarnings

jobs:
  test:
    uses: ./.github/workflows/ci.yml
    with:
      release: true

  release:
    runs-on: ubuntu-latest
    needs: test
    steps:
    # Check out with full history to generate release notes.
    - name: Checkout
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Set up toolchain
      run: rustup install
    - name: Release
      run: gh release create '${{ github.ref_name }}' --generate-notes
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  package:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
        - macos-13 # amd64
        - macos-14 # arm64
        - ubuntu-22.04
        - ubuntu-22.04-arm
        - windows-2022
        # https://github.com/actions/partner-runner-images/issues/77
        # - windows-11-arm
        include:
        - os: windows-2022
          extension: '.exe'
        # - os: windows-11-arm
        #   extension: '.exe'
    needs: release
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Cache
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/bin/
          ~/.cargo/registry/index/
          ~/.cargo/registry/cache/
          ~/.cargo/git/db/
          target/
        key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name: Set up toolchain
      run: rustup install
    - name: Install openssl (Windows)
      if: runner.os == 'Windows'
      run: |
        echo "OPENSSL_DIR=C:\Program Files\OpenSSL" >> $GITHUB_ENV
    - name: Build
      run: cargo build --release --all-features --workspace
    - name: Package
      id: package
      shell: pwsh
      run: |
        $name = 'akv-${{ runner.os }}-${{ runner.arch }}'.ToLowerInvariant() -replace 'x64', 'amd64'
        if ('${{ runner.os }}' -eq 'Windows') {
          $name = "$name.zip"
          $target = "target/release/$name"
          Compress-Archive -Path target/release/akv${{ matrix.extension }} -DestinationPath $target
        } else {
          $name = "$name.tar.gz"
          $target = "target/release/$name"
          tar czf "$target" -C target/release/ akv${{ matrix.extension }}
        }
        "name=$name" >> $env:GITHUB_OUTPUT
        "target=$target" >> $env:GITHUB_OUTPUT
    - name: Upload
      uses: actions/upload-artifact@v4
      with:
        name: ${{ steps.package.outputs.name }}
        path: ${{ steps.package.outputs.target }}
    - name: Publish
      run: gh release upload '${{ github.ref_name }}' '${{ steps.package.outputs.target }}'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  attest:
    runs-on: ubuntu-latest
    needs: package
    steps:
    - name: Download
      uses: actions/download-artifact@v4
    - name: Attest
      uses: actions/attest-build-provenance@v2
      with:
        subject-path: ${{ github.workspace }}/*

  # Publish separately to crates.io to allow retries e.g., expired token.
  publish:
    runs-on: ubuntu-latest
    needs: release
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Set up toolchain
      run: rustup install
    - name: Publish
      run: cargo publish
      env:
        CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}