This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
223 lines (200 loc) · 7.37 KB
/
pre-release.yml
File metadata and controls
223 lines (200 loc) · 7.37 KB
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Pre-Release
on:
workflow_dispatch:
inputs:
semver-type:
description: "Can be one of [major,minor,patch]. CAUTION: This will enforce a new pre-release with the specified semantic version type bumped."
required: false
env:
NODE_VERSION: 14
KEPTN_BOT_NAME: "Keptn Contrib Bot"
KEPTN_BOT_EMAIL: "keptn-contrib-bot@users.noreply.github.com"
RELEASE_NOTES_FILE: "RELEASE-BODY.md" # If you change this, then also adapt .gitignore!
PRERELEASE_KEYWORD: "next"
defaults:
run:
shell: bash
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v4.1.1
- name: Unit tests
uses: ./.github/actions/unit-tests
prepare:
name: Prepare pre-release run
runs-on: ubuntu-20.04
outputs:
next-version: ${{ steps.version_number.outputs.next-version }}
branch: ${{ steps.current_branch.outputs.branch }}
steps:
- name: Check SemVer input
env:
SEMVER_TYPE: ${{ github.event.inputs.semver-type }}
run: |
if [[ ! -z "$SEMVER_TYPE" ]]; then
echo "SemVer Type is defined. Checking for valid SemVer type..."
if [[ "$SEMVER_TYPE" == "major" ]] || [[ "$SEMVER_TYPE" == "minor" ]] || [[ "$SEMVER_TYPE" == "patch" ]]; then
echo "::notice::SemVer Type is correctly set to $SEMVER_TYPE! Continuing with this version bump..."
else
echo "::error::ERROR: Enforced SemVer does not match any of [major,minor,patch]!"
echo "Exiting..."
exit 1
fi
else
echo "::notice::No SemVer type defined, continuing with auto generated version number..."
fi
- name: Checkout repo
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Find next version number
id: version_number
env:
SEMVER_TYPE: ${{ github.event.inputs.semver-type }}
run: |
if [[ ! -z "$SEMVER_TYPE" ]]; then
npx standard-version@^9.3.2 \
--skip.commit \
--skip.tag \
--skip.changelog \
--prerelease "${{ env.PRERELEASE_KEYWORD }}" \
--release-as "$SEMVER_TYPE"
else
npx standard-version@^9.3.2 \
--skip.commit \
--skip.tag \
--skip.changelog \
--prerelease "${{ env.PRERELEASE_KEYWORD }}"
fi
NEXT_VERSION=$(cat VERSION.txt)
echo "::set-output name=next-version::${NEXT_VERSION}"
git checkout HEAD -- VERSION.txt
- name: Find current branch
id: current_branch
run: |
branch=${GITHUB_REF#refs/heads/}
echo "::set-output name=branch::${branch}"
############################################################################
# Build Docker Image
############################################################################
docker_build:
needs: prepare
name: Build Docker Image
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.prepare.outputs.next-version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.1
# load DOCKER_ORGANIZATION & IMAGE variable from .ci_env
- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .ci_env
- name: Docker Build
uses: keptn/gh-automation/.github/actions/docker-build@v1.6.0
with:
TAGS: |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}
BUILD_ARGS: |
version=${{ env.VERSION }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
############################################################################
# Build Helm Chart
############################################################################
build-helm-chart:
needs: prepare
name: Build Helm Charts
uses: ./.github/workflows/build-helm-chart.yml
with:
branch: ${{ needs.prepare.outputs.branch }}
version: ${{ needs.prepare.outputs.next-version }}
release: true
############################################################################
# Pre-Release
############################################################################
pre-release:
name: "Pre-Release"
runs-on: ubuntu-20.04
needs: [prepare, docker_build, build-helm-chart]
steps:
- name: Checkout repo
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Configure Git
env:
KEPTN_BOT_NAME: ${{ env.KEPTN_BOT_NAME }}
KEPTN_BOT_EMAIL: ${{ env.KEPTN_BOT_EMAIL }}
run: |
git config user.name "$KEPTN_BOT_NAME"
git config user.email "$KEPTN_BOT_EMAIL"
- name: Prepare GitHub Pre-Release Notes
env:
SEMVER_TYPE: ${{ github.event.inputs.semver-type }}
run: |
if [[ ! -z "$SEMVER_TYPE" ]]; then
npx standard-version@^9.3.2 \
--prerelease "${{ env.PRERELEASE_KEYWORD }}" \
-i "${{ env.RELEASE_NOTES_FILE }}" \
--skip.commit \
--skip.tag \
--header "" \
--release-as "$SEMVER_TYPE"
else
npx standard-version@^9.3.2 \
--prerelease "${{ env.PRERELEASE_KEYWORD }}" \
-i "${{ env.RELEASE_NOTES_FILE }}" \
--skip.commit \
--skip.tag \
--header ""
fi
- name: Create Pre-Release Package
id: create-release-package
env:
SEMVER_TYPE: ${{ github.event.inputs.semver-type }}
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
run: |
echo "🚀 Creating release package now..."
if [[ ! -z "$SEMVER_TYPE" ]]; then
npx standard-version@^9.3.2 \
--release-as "$SEMVER_TYPE" \
--prerelease "${{ env.PRERELEASE_KEYWORD }}" \
--skip.commit \
--skip.changelog
else
npx standard-version@^9.3.2 \
--prerelease "${{ env.PRERELEASE_KEYWORD }}" \
--skip.commit \
--skip.changelog
fi
echo "::set-output name=tag-name::$(git describe --tags --abbrev=0)"
# No need for a PR here, because we do not want any changes to be committed. Just push the pre-release tag
- name: Push Tags
run: |
git push --follow-tags
- name: Download Pre-Release Artifacts
uses: actions/download-artifact@v3
with:
path: ./dist
- name: Create GitHub Pre-Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.create-release-package.outputs.tag-name }}
run: |
gh release create "${{ env.RELEASE_TAG }}" --draft --prerelease --notes-file "${{ env.RELEASE_NOTES_FILE }}" --title "${{ env.RELEASE_TAG }}" ./dist/installer/*.tgz