-
Notifications
You must be signed in to change notification settings - Fork 158
195 lines (182 loc) · 6.55 KB
/
release.yaml
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
name: Release
permissions:
contents: read
on:
push:
branches:
- master
workflow_dispatch:
inputs:
release_tag:
description: 'Image tag in the format x.x.x(-rcx)'
required: true
type: string
draft_release:
description: 'Publish as a draft'
required: true
default: true
type: boolean
env:
DRAFT_RELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.draft_release == true && 'true' || 'false' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
run_if:
if: "${{ (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'pre-release: Update version to')) || github.event_name == 'workflow_dispatch' }}"
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.release_tag.outputs.release_tag }}
steps:
- run: echo "Triggered by ${{ github.event_name }}"
- run: 'echo "Draft release: ${{ env.DRAFT_RELEASE }}"'
- id: release_tag
env:
COMMIT_MESSAGE: ${{github.event.head_commit.message}}
run: |
if [[ ${{github.event_name}} == "push" ]]
then
[[ "${COMMIT_MESSAGE}" =~ ^pre-release:\ Update\ version\ to\ ([0-9]*\.[0-9]*\.[0-9]*(\-[0-9a-z]+)?)\ .*$ ]] && echo "release_tag=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "release_tag=${{inputs.release_tag}}" >> $GITHUB_OUTPUT
fi
create_tag:
needs: run_if
runs-on: ubuntu-latest
permissions:
contents: write
env:
RELEASE_TAG: ${{ needs.run_if.outputs.release_tag }}
outputs:
tag_url: ${{ steps.output_tag.outputs.tag_url }}
environment:
name: release
url: ${{ steps.output_tag.outputs.tag_url }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- id: create_tag
run: |
git config --global user.name 'Kasten Production'
git config --global user.email '[email protected]'
git tag -a "${RELEASE_TAG}" -m "Release version"
git push origin "${RELEASE_TAG}"
- id: output_tag
run: echo "tag_url=https://github.com/kanisterio/kanister/releases/tag/${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
release_packages:
runs-on: ubuntu-latest
needs: [run_if, create_tag]
permissions:
packages: write
contents: write
env:
RELEASE_TAG: ${{ needs.run_if.outputs.release_tag }}
outputs:
release: ${{ steps.output_release.outputs.release_url }}
environment:
name: release
url: ${{ steps.output_release.outputs.release_url }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ env.RELEASE_TAG }}
fetch-depth: 0
- name: build helm charts
run: |
export PACKAGE_FOLDER=helm_package
export HELM_RELEASE_REPO_URL=https://github.com/kanisterio/kanister/releases/download/${RELEASE_TAG}
export HELM_RELEASE_REPO_INDEX=https://charts.kanister.io/
make package-helm VERSION=${RELEASE_TAG}
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
- name: gorelease
run: make gorelease
env:
GHCR_LOGIN_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_LOGIN_USER: ${{ github.actor }}
GORELEASE_PARAMS: ${{ env.DRAFT_RELEASE == 'true' && '--draft' || '' }}
## Upload to use in docs publishing
- uses: actions/upload-artifact@v4
with:
name: helm-index
path: helm_package/index.yaml
- id: output_release
run: echo "release_url=https://github.com/kanisterio/kanister/releases/tag/${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
build_docs:
runs-on: ubuntu-latest
needs: [run_if, release_packages]
env:
RELEASE_TAG: ${{ needs.run_if.outputs.release_tag }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ env.RELEASE_TAG }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
package_json_file: docs_new/package.json
version: 8
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install dependencies
run: pnpm install
working-directory: ./docs_new
- name: Build with VitePress
run: pnpm docs:build
working-directory: ./docs_new
- name: download helm index
uses: actions/download-artifact@v4
with:
name: helm-index
path: docs_new/.vitepress/dist/helm_charts/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs_new/.vitepress/dist
publish_docs_and_charts:
needs: build_docs
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
## TODO: using https://github.com/slackapi/slack-github-action/blob/main/README.md#technique-3-slack-incoming-webhook
## we need to set up incoming webhook
## Alternatively we can also configure a bot token https://github.com/slackapi/slack-github-action/blob/main/README.md#technique-2-slack-app
# notify_slack:
# needs: [release_packages, build_docs]
# runs-on: ubuntu-latest
# steps:
# - name: Send slack notification
# id: slack
# uses: slackapi/[email protected]
# with:
# ## TODO: optionally include more information?
# payload: |
# {
# "text": "Kanister release published: ${RELEASE_URL}",
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
# RELEASE_URL: ${{ needs.release_packages.outputs.release_url }}
release_example_docker_images:
needs: [run_if, release_packages]
permissions:
packages: write
contents: read
uses: ./.github/workflows/build_example_images.yaml
with:
image_tag: ${{ needs.run_if.outputs.release_tag }}
ref: ${{ needs.run_if.outputs.release_tag }}