akv-cli 0.11.1

The Azure Key Vault CLI (unofficial) can read secrets from Key Vault, securely pass secrets to other commands or inject them into configuration files, encrypt and decrypt secrets, and managed keys and secrets in Key Vault.
Documentation
name: winget

on:
  workflow_call:
    inputs:
      tag:
        description: The tag to release e.g., v0.1.0
        required: true
        type: string
    secrets:
      WINGET_CREATE_GITHUB_TOKEN:
        required: true
  workflow_dispatch:
    inputs:
      tag:
        description: The tag to release e.g., v0.1.0
        required: true
        type: string

defaults:
  run:
    shell: bash

jobs:
  validate:
    runs-on: windows-latest
    outputs:
      tag: ${{ steps.vars.outputs.tag }}
      version: ${{ steps.vars.outputs.version }}
      url_base: ${{ steps.vars.outputs.url_base }}
      release_url: ${{ steps.vars.outputs.release_url }}
      manifest_root: ${{ steps.vars.outputs.manifest_root }}
      manifest_path: ${{ steps.vars.outputs.manifest_path }}
      release_date: ${{ steps.vars.outputs.release_date }}
    steps:
    - name: Set WinGet Variables
      id: vars
      run: |
        tag='${{ inputs.tag || github.ref_name }}'
        version="${tag#v}"
        url_base="${{ github.server_url }}/${{ github.repository }}/releases/download/${tag}"
        release_url="${{ github.server_url }}/${{ github.repository }}/releases/tag/${tag}"
        manifest_root="${RUNNER_TEMP}/winget"
        manifest_path="${manifest_root}/manifests/h/heaths/akv/${version}"
        date="$(date +%Y-%m-%d)"
        echo "WINGET_TAG=$tag" >> "$GITHUB_ENV"
        echo "WINGET_VERSION=$version" >> "$GITHUB_ENV"
        echo "WINGET_URL_BASE=$url_base" >> "$GITHUB_ENV"
        echo "WINGET_RELEASE_URL=$release_url" >> "$GITHUB_ENV"
        echo "WINGET_MANIFEST_ROOT=$manifest_root" >> "$GITHUB_ENV"
        echo "WINGET_MANIFEST_PATH=$manifest_path" >> "$GITHUB_ENV"
        echo "WINGET_RELEASE_DATE=$date" >> "$GITHUB_ENV"
        echo "tag=$tag" >> "$GITHUB_OUTPUT"
        echo "version=$version" >> "$GITHUB_OUTPUT"
        echo "url_base=$url_base" >> "$GITHUB_OUTPUT"
        echo "release_url=$release_url" >> "$GITHUB_OUTPUT"
        echo "manifest_root=$manifest_root" >> "$GITHUB_OUTPUT"
        echo "manifest_path=$manifest_path" >> "$GITHUB_OUTPUT"
        echo "release_date=$date" >> "$GITHUB_OUTPUT"
    - name: Install WinGetCreate
      run: |
        if winget source list | grep -qiE '^\s*msstore\s'; then
          winget source remove msstore || echo "Warning: failed to remove msstore source"
        fi
        winget install -e Microsoft.WingetCreate --source winget --accept-source-agreements --accept-package-agreements --silent
    - name: Generate WinGet package
      run: |
        wingetcreate update \
          --urls "${WINGET_URL_BASE}/akv-windows-amd64.zip|x64" "${WINGET_URL_BASE}/akv-windows-arm64.zip|arm64" \
          --version "$WINGET_VERSION" \
          --release-notes-url "$WINGET_RELEASE_URL" \
          --release-date "$WINGET_RELEASE_DATE" \
          --out "$WINGET_MANIFEST_ROOT" \
          heaths.akv
    - name: Archive WinGet package
      id: archive
      run: |
        archive="${RUNNER_TEMP}/winget-manifests-${WINGET_VERSION}.zip"
        7z a "$archive" "${WINGET_MANIFEST_ROOT}/manifests/*"
        echo "manifest_archive=$archive" >> "$GITHUB_OUTPUT"
    - name: Upload WinGet package artifact
      if: always()
      uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
      with:
        name: winget-manifests-${{ env.WINGET_VERSION }}
        path: ${{ steps.archive.outputs.manifest_archive }}
    - name: Validate WinGet package
      run: |
        winget validate --manifest "$WINGET_MANIFEST_PATH" --ignore-warnings
        # `winget install` requires enabling LocalManifestFiles,
        # but we have no practical way to verify install because we'd have to restart the shell.
  update:
    needs: validate
    runs-on: windows-latest
    environment:
      name: winget
      url: https://github.com/microsoft/winget-pkgs/pulls/heaths
    env:
      WINGET_TAG: ${{ needs.validate.outputs.tag }}
      WINGET_VERSION: ${{ needs.validate.outputs.version }}
      WINGET_URL_BASE: ${{ needs.validate.outputs.url_base }}
      WINGET_RELEASE_URL: ${{ needs.validate.outputs.release_url }}
      WINGET_MANIFEST_ROOT: ${{ needs.validate.outputs.manifest_root }}
      WINGET_MANIFEST_PATH: ${{ needs.validate.outputs.manifest_path }}
      WINGET_RELEASE_DATE: ${{ needs.validate.outputs.release_date }}
    steps:
    - name: Install WinGetCreate
      run: |
        if winget source list | grep -qiE '^\s*msstore\s'; then
          winget source remove msstore || echo "Warning: failed to remove msstore source"
        fi
        winget install -e Microsoft.WingetCreate --source winget --accept-source-agreements --accept-package-agreements --silent
    - name: Update WinGet package
      run: |
        wingetcreate update \
          --urls "${WINGET_URL_BASE}/akv-windows-amd64.zip|x64" "${WINGET_URL_BASE}/akv-windows-arm64.zip|arm64" \
          --version "$WINGET_VERSION" \
          --release-notes-url "$WINGET_RELEASE_URL" \
          --release-date "$WINGET_RELEASE_DATE" \
          --submit \
          heaths.akv
      env:
        WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }}