Skip to content

Commit

Permalink
ci: automate bumping ZITADEL version (zitadel#43)
Browse files Browse the repository at this point in the history
* add bump ZITADEL workflow

* use semanticoutput

* test action

* fix trigger

* remove if

* add token

* syntax and typos

* syntax

* typos

* typo

* fix references

* debug

* reading multiple yaml keys is not supported

* debug

* fix read yaml usage

* typo

* don't fail on semver conditionals

* fix action ref

* typo

* debug

* update Chart.yaml

* fix order

* automerge and approve

* [create-pull-request] automated change (zitadel#4)

Co-authored-by: eliobischof <eliobischof@users.noreply.github.com>

* Revert "[create-pull-request] automated change (zitadel#4)"

This reverts commit cced733.

* gh token scopes

* test bump

* [create-pull-request] automated change (zitadel#5)

Co-authored-by: eliobischof <eliobischof@users.noreply.github.com>

* Revert "[create-pull-request] automated change (zitadel#5)"

This reverts commit d5e7bc4.

* cleanup

* remove newline

* use app token

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: eliobischof <eliobischof@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 13, 2023
1 parent b446c12 commit 15f9482
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Bump Version

on:
repository_dispatch:
types:
- zitadel-released

permissions:
contents: write
pull-requests: write

jobs:
bump:
runs-on: ubuntu-20.04
permissions:
contents: write
pull-requests: write
steps:
- id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Read Current Chart Version
id: current-chart-version
uses: jbutcher5/read-yaml@1.6
with:
file: './charts/zitadel/Chart.yaml'
key-path: '["version"]'

- name: Read Current ZITADEL Version
id: current-zitadel-version
uses: jbutcher5/read-yaml@1.6
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 Last ZITADEL Version
id: parsed-last-zitadel-version
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ steps.current-zitadel-version.outputs.data }}

- name: Set Version Type
id: set-version-type
run: |
[ ${{ github.event.client_payload.semanticoutputs.new_release_patch_version }} -gt ${{ steps.parsed-last-zitadel-version.outputs.patch }} ] && echo '::set-output name=type::PATCH' || true
[ ${{ github.event.client_payload.semanticoutputs.new_release_minor_version }} -gt ${{ steps.parsed-last-zitadel-version.outputs.minor }} ] && echo '::set-output name=type::MINOR' || true
[ ${{ github.event.client_payload.semanticoutputs.new_release_major_version }} -gt ${{ steps.parsed-last-zitadel-version.outputs.major }} ] && echo '::set-output name=type::MAJOR' || true
- name: Bump Chart Version
uses: jessicalostinspace/bump-semantic-version-action@v1.0.1
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: ${{ github.event.client_payload.semanticoutputs.new_release_version }}
updateFile: true
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 }}
updateFile: true
commitChange: false
createPR: false

- name: Print Chart.yaml
run: cat charts/zitadel/Chart.yaml

- name: Create Pull Request
id: pull-request
uses: peter-evans/create-pull-request@v4
with:
title: Bump ZITADEL Version
branch: create-pull-request/bump
delete-branch: true

- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Enable Pull Request Automerge
if: steps.pull-request.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ steps.generate-token.outputs.token }}
pull-request-number: ${{ steps.pull-request.outputs.pull-request-number }}
merge-method: squash

- name: Auto approve
if: steps.pull-request.outputs.pull-request-operation == 'created'
uses: juliangruber/approve-pull-request-action@v1
with:
github-token: ${{ steps.generate-token.outputs.token }}
number: ${{ steps.pull-request.outputs.pull-request-number }}

0 comments on commit 15f9482

Please sign in to comment.