-
Notifications
You must be signed in to change notification settings - Fork 57
157 lines (137 loc) · 5.41 KB
/
bump.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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@v7
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 }}