diff --git a/.github/workflows/publish-to-other-than-github.yaml b/.github/workflows/publish-to-other-than-github.yaml index 4e3d951398..4648c8261a 100644 --- a/.github/workflows/publish-to-other-than-github.yaml +++ b/.github/workflows/publish-to-other-than-github.yaml @@ -8,34 +8,18 @@ name: Publish Release to other package registries than Github on: - workflow_dispatch: - inputs: - version: - type: string - description: 'Version of the latest release (e.g. v0.42.0)' - required: false - default: '' repository_dispatch: - types: [ocm-cli-release] + types: [publish-ocm-cli] jobs: push-to-aur: name: Update Arch Linux User Repository + if: github.event.client_payload.push-to-aur && github.event.client_payload.version != '' runs-on: ubuntu-latest steps: - name: Ensure proper version - run: | - if [ -n "${{ github.event.inputs.version }}" ]; then - echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} | tr -d ['v'])" >> $GITHUB_ENV - exit 0 - fi - if [ -n "${{ github.event.client_payload.version }}" ]; then - echo "RELEASE_VERSION=$(echo ${{ github.event.client_payload.version }} | tr -d ['v'])" >> $GITHUB_ENV - exit 0 - fi - echo "Version not provided" - exit 1 + run: echo "RELEASE_VERSION=$(echo ${{ github.event.client_payload.version }} | tr -d ['v'])" >> $GITHUB_ENV - name: Install SSH key uses: shimataro/ssh-key-action@v2 with: @@ -56,24 +40,13 @@ jobs: push-to-chocolatey: name: Update Chocolatey + if: github.event.client_payload.push-to-chocolatey && github.event.client_payload.version != '' runs-on: windows-latest steps: - name: Ensure proper version run: | - $workflow_version = "${{ github.event.inputs.version }}" - $repository_version = "${{ github.event.client_payload.version }}" - if (-not ([string]::IsNullOrEmpty($workflow_version))) { - $workflow_version = "$workflow_version" -replace 'v' - echo "RELEASE_VERSION=$workflow_version" | Out-File $env:GITHUB_ENV - exit 0 - } - if (-not ([string]::IsNullOrEmpty($repository_version))) { - $repository_version = "$repository_version" -replace 'v' - echo "RELEASE_VERSION=($repository_version -replace 'v')" | Out-File $env:GITHUB_ENV - exit 0 - } - Write-Host "Version not provided" - exit 1 + $version = "${{ github.event.client_payload.version }}" -replace 'v' + echo "RELEASE_VERSION=$version" | Out-File $env:GITHUB_ENV - name: Generate token id: generate_token uses: tibdex/github-app-token@v2 @@ -91,24 +64,13 @@ jobs: push-to-winget: name: Update Winget + if: github.event.client_payload.push-to-winget && github.event.client_payload.version != '' runs-on: windows-latest steps: - name: Ensure proper version run: | - $workflow_version = "${{ github.event.inputs.version }}" - $repository_version = "${{ github.event.client_payload.version }}" - if (-not ([string]::IsNullOrEmpty($workflow_version))) { - $workflow_version = "$workflow_version" -replace 'v' - echo "RELEASE_VERSION=$workflow_version" | Out-File $env:GITHUB_ENV - exit 0 - } - if (-not ([string]::IsNullOrEmpty($repository_version))) { - $repository_version = "$repository_version" -replace 'v' - echo "RELEASE_VERSION=$repository_version" | Out-File $env:GITHUB_ENV - exit 0 - } - Write-Host "Version not provided" - exit 1 + $version = "${{ github.event.client_payload.version }}" -replace 'v' + echo "RELEASE_VERSION=$version" | Out-File $env:GITHUB_ENV - name: Generate token id: generate_token uses: tibdex/github-app-token@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5091f797ab..c834a6500b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -280,6 +280,6 @@ jobs: uses: peter-evans/repository-dispatch@v3 with: token: ${{ steps.generate_token.outputs.token }} - repository: open-component-model/ocm - event-type: ocm-cli-release - client-payload: '{"version": "${{ env.RELEASE_VERSION }}"}' \ No newline at end of file + repository: ${{ github.repository_owner }}/ocm + event-type: publish-ocm-cli + client-payload: '{"version":"${{ env.RELEASE_VERSION }}","push-to-aur":true,"push-to-chocolatey":true,"push-to-winget":true}' diff --git a/.github/workflows/retrigger-publish-to-other.yaml b/.github/workflows/retrigger-publish-to-other.yaml new file mode 100644 index 0000000000..6226bf3eb4 --- /dev/null +++ b/.github/workflows/retrigger-publish-to-other.yaml @@ -0,0 +1,60 @@ +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: | + 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 }}}'