constellation/.github/workflows/on-release.yml

85 lines
2.6 KiB
YAML
Raw Normal View History

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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
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' }}