constellation/.github/workflows/on-release.yml
Paul Meyer 632b24e7cd
ci: fix version publishing on release (#1658)
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2023-04-14 18:04:03 +02:00

85 lines
2.6 KiB
YAML

name: Make updated OS images available on release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Semantic version tag of the release (vX.Y.Z)."
required: true
latest:
description: "Whether to update the latest tag."
type: boolean
default: false
jobs:
update:
runs-on: ubuntu-22.04
outputs:
latest: ${{ steps.input-passthrough.outputs.latest }}${{ steps.check-last-release.outputs.latest }}
steps:
- name: Checkout
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
- name: Override latest
if: github.event.inputs.latest == 'true'
id: input-passthrough
run: echo "latest=true" | tee -a "$GITHUB_OUTPUT"
- name: Check if should mark latest
if: github.event.inputs.latest != 'true'
id: check-last-release
env:
REPO: edgelesssys/constellation
GH_TOKEN: ${{ github.token }}
run: |
latest_release_tag=$(
gh api \
-H "Accept: application/vnd.github+json" \
"/repos/${REPO}/releases/latest" \
| jq -r '.tag_name'
)
current_tag=${{ github.event.release.tag_name }}${{ github.event.inputs.tag }}
echo "Latest release tag: ${latest_release_tag}"
echo "Current tag: ${current_tag}"
if [[ "${latest_release_tag}" == "${current_tag}" ]]; then
echo "latest=true" | tee -a "$GITHUB_OUTPUT"
else
echo "latest=false" | tee -a "$GITHUB_OUTPUT"
fi
add-image-version-to-versionsapi:
needs: [update]
name: "Add image version to versionsapi"
permissions:
contents: read
id-token: write
uses: ./.github/workflows/versionsapi.yml
with:
command: add
add_release: true
stream: stable
version: ${{ github.event.release.tag_name }}${{ github.event.inputs.tag }}
kind: image
add_latest: ${{ needs.update.outputs.latest == 'true' }}
add-cli-version-to-versionsapi:
needs: [update, add-image-version-to-versionsapi] # run workflow calls after each other
name: "Add CLI version to versionsapi"
permissions:
contents: read
id-token: write
uses: ./.github/workflows/versionsapi.yml
with:
command: add
add_release: true
stream: stable
version: ${{ github.event.release.tag_name }}${{ github.event.inputs.tag }}
kind: cli
add_latest: ${{ needs.update.outputs.latest == 'true' }}