Bump Version #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bump Version | |
on: | |
repository_dispatch: | |
types: | |
- zitadel-released | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'ZITADEL Tag' | |
required: false | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Validate the manually given input tag, if any | |
if: ${{ (github.event_name == 'workflow_dispatch') && (github.event.inputs.tag != '') }} | |
id: check-input | |
run: | | |
INPUT=${{github.event.inputs.tag}} | |
if ! [[ ${INPUT} =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then | |
echo "supplied invalid version number: ${INPUT}!" | |
echo "must be of schema: vX.X.X" | |
exit 1 | |
fi | |
- name: Get Latest ZITADEL Release Version | |
id: latest-tag | |
uses: oprypin/find-latest-tag@v1 | |
with: | |
repository: zitadel/zitadel | |
releases-only: true | |
sort-tags: true | |
# ignore prereleases | |
regex: '^v([0-9]+)\.([0-9]+)\.([0-9]+)$' | |
- name: Decide on Target ZITADEL Version | |
id: target-zitadel-version | |
run: | | |
INPUT=${{ github.event.inputs.tag }} | |
LATEST=${{ steps.latest-tag.outputs.tag }} | |
TARGET_ZITADEL_VERSION=${INPUT:-${LATEST}} | |
echo "input tag: ${INPUT}" | |
echo "latest tag: ${LATEST}" | |
echo "going to target zitadel version: ${TARGET_ZITADEL_VERSION}" | |
echo "tag=${TARGET_ZITADEL_VERSION}" >> $GITHUB_OUTPUT | |
- name: Parse Target ZITADEL Version into Major, Minor, Patch | |
id: parsed-target-zitadel-version | |
uses: release-kit/semver@v2 | |
with: | |
source: string | |
string: ${{ steps.target-zitadel-version.outputs.tag }} | |
- id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Read Current Chart Version | |
id: current-chart-version | |
uses: jbutcher5/[email protected] | |
with: | |
file: './charts/zitadel/Chart.yaml' | |
key-path: '["version"]' | |
- name: Read Current ZITADEL Version | |
id: current-zitadel-version | |
uses: jbutcher5/[email protected] | |
with: | |
file: './charts/zitadel/Chart.yaml' | |
key-path: '["appVersion"]' | |
- name: Print Current Versions | |
run: | | |
echo "Chart Version: ${{ steps.current-chart-version.outputs.data }}" | |
echo "ZITADEL Version: ${{ steps.current-zitadel-version.outputs.data }}" | |
- name: Parse Currently ZITADEL Version into Major, Minor, Patch | |
id: parsed-last-zitadel-version | |
uses: release-kit/semver@v2 | |
with: | |
source: 'string' | |
string: ${{ steps.current-zitadel-version.outputs.data }} | |
- name: Set Version Update Type | |
id: set-version-type | |
run: | | |
[ ${{ steps.parsed-target-zitadel-version.outputs.patch }} -gt ${{ steps.parsed-last-zitadel-version.outputs.patch }} ] && echo 'type=PATCH' >> $GITHUB_OUTPUT || true | |
[ ${{ steps.parsed-target-zitadel-version.outputs.minor }} -gt ${{ steps.parsed-last-zitadel-version.outputs.minor }} ] && echo 'type=MINOR' >> $GITHUB_OUTPUT || true | |
[ ${{ steps.parsed-target-zitadel-version.outputs.major }} -gt ${{ steps.parsed-last-zitadel-version.outputs.major }} ] && echo 'type=MAJOR' >> $GITHUB_OUTPUT || true | |
- name: Bump Chart Version | |
uses: jessicalostinspace/[email protected] | |
id: bumped-chart-version | |
with: | |
semantic-version: ${{ steps.current-chart-version.outputs.data }} | |
version-type: ${{ steps.set-version-type.outputs.type }} | |
- name: Update ZITADEL Version | |
uses: fjogeleit/yaml-update-action@main | |
with: | |
valueFile: 'charts/zitadel/Chart.yaml' | |
propertyPath: 'appVersion' | |
value: ${{ steps.target-zitadel-version.outputs.tag }} | |
commitChange: false | |
createPR: false | |
- name: Update Chart Version | |
uses: fjogeleit/yaml-update-action@main | |
with: | |
valueFile: 'charts/zitadel/Chart.yaml' | |
propertyPath: 'version' | |
value: ${{ steps.bumped-chart-version.outputs.bumped-semantic-version }} | |
commitChange: false | |
createPR: false | |
- name: Print Chart.yaml | |
run: cat charts/zitadel/Chart.yaml | |
- name: Generate GitHub App Token | |
id: generate-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.ZITADEL_WORKFLOW_APP_ID }} | |
private-key: ${{ secrets.ZITADEL_WORKFLOW_APP_PRIVATE_KEY }} | |
- name: Create Pull Request | |
id: pull-request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
title: Bump ZITADEL Version | |
branch: create-pull-request/bump | |
delete-branch: true | |
# We can't just use the GITHUB_TOKEN here, as it wouldn't trigger other workflows needed for the required checks. | |
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs | |
token: ${{ steps.generate-token.outputs.token }} | |
- name: Enable Automerge | |
if: steps.pull-request.outputs.pull-request-operation == 'created' | |
run: gh pr merge --squash --auto "${{ steps.pull-request.outputs.pull-request-number }}" | |
env: | |
GH_TOKEN: ${{ steps.generate-token.outputs.token }} | |
- name: Approve | |
if: steps.pull-request.outputs.pull-request-operation == 'created' | |
run: gh pr review --approve "${{ steps.pull-request.outputs.pull-request-number }}" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |