-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (171 loc) · 5.81 KB
/
release_trigger.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Release Trigger
on:
workflow_dispatch:
workflow_call:
inputs:
draft:
type: boolean
required: false
release_overwrite:
type: string
required: false
secrets:
token:
required: true
user:
required: true
email:
required: true
env:
GH_TOKEN: ${{ secrets.token || secrets.YNPUT_BOT_TOKEN }}
GH_USER: ${{ secrets.user || secrets.CI_USER }}
GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }}
DRAFT: ${{ inputs.draft }}
NEXT_RELEASE: ${{ inputs.release_overwrite }}
ARTIFACT_NAME: "${{ vars.PROJECT_NAME }}-package"
PROJECT_NAME: "${{ vars.PROJECT_NAME }}"
REQUIRED_VARS: MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME
CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || '' }}"
jobs:
verify-latest-release:
uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@main
with:
repo: ${{ github.repository }}
expect_release: true
secrets:
gh_token: ${{ secrets.token }}
verify-repo-secrets:
uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@main
with:
repo: ${{ github.repository }}
secrets:
gh_token: ${{ secrets.token }}
gh_user: ${{ secrets.user }}
gh_email: ${{ secrets.email }}
verify-repo-vars:
uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@main
with:
variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME"
repo: ${{ github.repository }}
secrets:
gh_token: ${{ secrets.token }}
validate-pr-information:
# TODO update branch ref
needs:
- verify-latest-release
uses: ynput/ops-repo-automation/.github/workflows/verify_pr_data.yml@main
with:
repo: ${{ github.repository }}
base_branch: "develop"
latest_release: ${{ needs.verify-latest-release.outputs.date_published }}
changelog_order: ${{ vars.CHANGELOG_ORDER || '' }}
secrets:
gh_token: ${{ secrets.token }}
increment-version:
runs-on: ubuntu-latest
needs:
- validate-pr-information
outputs:
next-version: "${{ steps.set-tag.outputs.NEXT_TAG }}"
steps:
- name: 🔼 Get next Version Tag
if: ${{ ! inputs.release_overwrite }}
uses: reecetech/[email protected]
id: calculated_version_tag
with:
scheme: semver
increment: ${{ needs.validate-pr-information.outputs.bump-increment }}
release_branch: ${{ vars.MAIN_BRANCH }}
use_api: true
- name: Set next version tag
id: set-tag
env:
TAG: "${{ steps.calculated_version_tag.outputs.major-version }}.${{ steps.calculated_version_tag.outputs.minor-version }}.${{ steps.calculated_version_tag.outputs.patch-version }}"
run: |
if [ "${{ env.TAG }}" == ".." ]; then
echo "NEXT_TAG=${{ inputs.release_overwrite }}" >> $GITHUB_OUTPUT
exit 0
fi
echo "NEXT_TAG=${{ env.TAG }}" >> $GITHUB_OUTPUT
exit 0
merge-to-main:
needs:
- increment-version
- verify-latest-release
- verify-repo-secrets
- verify-repo-vars
uses: ynput/ops-repo-automation/.github/workflows/merge_branch.yml@main
with:
repo: ${{ github.repository }}
checkout_branch: ${{ vars.MAIN_BRANCH }}
merge_from_branch: ${{ github.ref_name }}
secrets:
gh_token: ${{ secrets.token }}
gh_user: ${{ secrets.user }}
gh_email: ${{ secrets.email }}
build-from-main:
needs:
- increment-version
- merge-to-main
uses: ynput/ops-repo-automation/.github/workflows/build_from_branch.yml@main
with:
repo: ${{ github.repository }}
branch_name: ${{ vars.MAIN_BRANCH }}
project_name: ${{ vars.PROJECT_NAME }}
artifact_name: "${{ vars.PROJECT_NAME }}-package"
next_version: "${{ inputs.release_overwrite || needs.increment-version.outputs.next-version }}"
secrets:
gh_token: ${{ secrets.token }}
gh_user: ${{ secrets.user }}
gh_email: ${{ secrets.email }}
update-develop:
needs:
- build-from-main
- increment-version
uses: ynput/ops-repo-automation/.github/workflows/update_branch.yml@main
with:
repo: ${{ github.repository }}
checkout_branch: ${{ github.ref_name }}
update_from_branch: ${{ vars.MAIN_BRANCH }}
next_version: "${{ needs.increment-version.outputs.next-version }}"
secrets:
gh_token: ${{ secrets.token }}
gh_user: ${{ secrets.user }}
gh_email: ${{ secrets.email }}
create-release:
runs-on: ubuntu-latest
needs:
- validate-pr-information
- build-from-main
- increment-version
env:
NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}"
CHANGELOG: "${{ needs.validate-pr-information.outputs.changelog }}"
steps:
- name: 🔽 Download zip artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
- name: 🚀 Create Github Release
uses: ncipollo/release-action@v1
with:
commit: "${{ vars.MAIN_BRANCH }}"
tag: "${{ env.NEXT_VERSION }}"
body: ${{ env.CHANGELOG || false }}
generateReleaseNotes: "${{ !env.CHANGELOG }}"
artifacts: |
${{ needs.build-from-main.outputs.artifact_file }}
token: ${{ env.GH_TOKEN }}
draft: ${{ env.DRAFT }}
verify-release:
needs:
- create-release
- increment-version
uses: ynput/ops-repo-automation/.github/workflows/verify_created_release.yml@main
with:
repo: ${{ github.repository }}
expected_release_name: ${{ needs.increment-version.outputs.next-version }}
draft_release: ${{ inputs.draft }}
secrets:
gh_token: ${{ secrets.token }}
# TODO verify tag position