name: Release

permissions: {}

on:
  workflow_dispatch:
    inputs:
      target:
        description: Package to be released
        required: true
        type: choice
        options:
          - install-action
          - install-action-manifest-schema
      version:
        description: Version to be increased
        required: true
        type: choice
        options:
          - patch
          - minor
          - major

concurrency:
  group: ${{ github.workflow }}
  cancel-in-progress: false

jobs:
  release:
    if: github.repository_owner == 'taiki-e' && inputs.target == 'install-action'
    uses: taiki-e/github-actions/.github/workflows/action-release.yml@931686d4e4cf88b13e790040727ccde2dba8ec62 # main
    permissions:
      contents: write # for taiki-e/create-gh-release-action
    secrets:
      PUSH_TOKEN_APP_CLIENT_ID: ${{ secrets.PUSH_TOKEN_APP_CLIENT_ID }}
      PUSH_TOKEN_APP_PRIVATE_KEY: ${{ secrets.PUSH_TOKEN_APP_PRIVATE_KEY }}
    with:
      version: ${{ inputs.version }}
      post-commit-script: tools/ci/release-post-commit.sh

  release-manifest-schema:
    if: github.repository_owner == 'taiki-e' && inputs.target == 'install-action-manifest-schema'
    uses: taiki-e/github-actions/.github/workflows/rust-release.yml@931686d4e4cf88b13e790040727ccde2dba8ec62 # main
    permissions:
      contents: write # for taiki-e/create-gh-release-action
      id-token: write # for rust-lang/crates-io-auth-action
      attestations: write # unused (used when options for uploading binaries are set)
    secrets:
      PUSH_TOKEN_APP_CLIENT_ID: ${{ secrets.PUSH_TOKEN_APP_CLIENT_ID }}
      PUSH_TOKEN_APP_PRIVATE_KEY: ${{ secrets.PUSH_TOKEN_APP_PRIVATE_KEY }}
    with:
      version: ${{ inputs.version }}
      tag-prefix: install-action-manifest-schema-
      package: install-action-manifest-schema
      changelog: tools/manifest-schema/CHANGELOG.md
      title: $prefix $version
      prefix: install-action-manifest-schema
      commit-prefix: 'manifest-schema: '
