-
Notifications
You must be signed in to change notification settings - Fork 156
169 lines (159 loc) · 5.97 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
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@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
- name: gorelease
run: make gorelease
env:
GHCR_LOGIN_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_LOGIN_USER: ${{ github.actor }}
GORELEASE_PARAMS: ${{ env.DRAFT_RELEASE == 'true' && '--draft' || '' }}
- id: output_release
run: echo "release_url=https://github.com/kanisterio/kanister/releases/tag/${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
build_docs:
needs: [run_if, release_packages]
permissions:
contents: read
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
uses: ./.github/workflows/publish_docs.yaml
with:
release_tag: ${{ needs.run_if.outputs.release_tag }}
publish_charts:
runs-on: ubuntu-latest
needs: [run_if, release_packages]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
RELEASE_TAG: ${{ needs.run_if.outputs.release_tag }}
steps:
- name: clone helm pages
run: |
git clone https://infraq:${GH_TOKEN}@github.com/kanisterio/kanister-charts
- name: Download the helm index
working-directory: ./kanister-charts
run: |
curl https://github.com/kanisterio/kanister/releases/download/${RELEASE_TAG}/helm_index.yaml -f -L -o index.yaml
- name: Commit changes
working-directory: ./kanister-charts
run: |
git config --global user.name 'Kasten Production'
git config --global user.email '[email protected]'
git add -A
git commit -s -m "Update chart index to ${RELEASE_TAG}"
- name: Push changes
working-directory: ./kanister-charts
run: |
git push
## 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 }}