Skip to content

Manually retrigger the publishing of ocm-cli to other repositories #4

Manually retrigger the publishing of ocm-cli to other repositories

Manually retrigger the publishing of ocm-cli to other repositories #4

name: Manually retrigger the publishing of ocm-cli to other repositories
on:
workflow_dispatch:
inputs:
version:
type: string
description: Which version (e.g. v0.42.0) do you want to publish?
required: true
default: ''
push-to-aur:
type: boolean
description: Do you want to push to the Arch Linux User Repository?
required: false
default: false
push-to-chocolatey:
type: boolean
description: Do you want to push to Chocolatey?
required: false
default: false
push-to-winget:
type: boolean
description: Do you want to push to Winget?
required: false
default: false
jobs:
retrigger:
name: Create new "Release Publish Event"
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.OCMBOT_APP_ID }}
private_key: ${{ secrets.OCMBOT_PRIV_KEY }}
- name: Ensure proper version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "Version not provided"
exit 1
fi
# let's check if the version is already published
curl -sSL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/open-component-model/ocm/releases > releases.json
jq -r '.[] | .tag_name' releases.json | grep -v -E '.*-rc|latest' > versions.txt
if grep -Fxq '${{ github.event.inputs.version }}' versions.txt; then
echo "Version (${{ github.event.inputs.version }}) found!"
else
echo "Version (${{ github.event.inputs.version }}) not found! This are the availble ones:"
cat versions.txt
exit 1
fi
echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} )" >> $GITHUB_ENV
- name: Publish Event
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.generate_token.outputs.token }}
repository: ${{ github.repository_owner }}/ocm
event-type: publish-ocm-cli
client-payload: '{"version":"${{ env.RELEASE_VERSION }}","push-to-aur":${{ github.event.inputs.push-to-aur }},"push-to-chocolatey":${{ github.event.inputs.push-to-chocolatey }},"push-to-winget":${{ github.event.inputs.push-to-winget }}}'