-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (152 loc) · 5.6 KB
/
release.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
name: Release Kusk Gateway API
concurrency:
group: "release"
cancel-in-progress: true
defaults:
run:
shell: bash
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
jobs:
release:
name: Create and upload release-artifacts
if: github.event.base_ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker Metadata for Kusk Gateway API
id: meta
uses: docker/metadata-action@v3
with:
images: kubeshop/kusk-gateway-api
tags: |
type=match,pattern=v(.*)
type=sha
flavor: |
latest=true
- name: Docker Metadata for Kusk Gateway API Websocket
id: meta-websocket
uses: docker/metadata-action@v3
with:
images: kubeshop/kusk-gateway-api-websocket
tags: |
type=match,pattern=v(.*)
type=sha
flavor: |
latest=true
- name: setup-goreleaser-environment-variables
run: |
echo "VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
- name: Build and Push Kusk Gateway API
uses: docker/build-push-action@v2
with:
context: .
file: ./build/api-server/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TELEMETRY_TOKEN=${{ secrets.TELEMETRY_TOKEN }}
VERSION=${{ env.VERSION }}
- name: Build and Push Kusk Gateway API Websocket
uses: docker/build-push-action@v2
with:
context: .
file: ./build/websocket/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-websocket.outputs.tags }}
labels: ${{ steps.meta-websocket.outputs.labels }}
build-args: |
TELEMETRY_TOKEN=${{ secrets.TELEMETRY_TOKEN }}
VERSION=${{ env.VERSION }}
- name: GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: v1.6.3
args: release --rm-dist --skip-sign
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
helm_chart_version_bump:
name: "Trigger Helm chart appVersion update"
needs: "release"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: "kubeshop/helm-charts"
ref: "main"
fetch-depth: 0
token: ${{ secrets.CI_BOT_TOKEN }}
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Bump Kusk Gateway API chart
run: |
# sets appVersion in the Chart.yaml
echo New appVersion: ${{ github.ref_name }}
sed -i -e "s/^appVersion: .*$/appVersion: \"${{ github.ref_name }}\"/" charts/kusk-gateway-api/Chart.yaml
# Bumps charts patch version
CURRENT_VERSION=$(sed -n -e "s/^version: \(.*\)$/\1/p" charts/kusk-gateway-api/Chart.yaml)
echo Current chart version ${CURRENT_VERSION}
NEW_VERSION=$(echo $CURRENT_VERSION |awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
echo New version ${NEW_VERSION}
sed -i -e "s/^version: .*/version: ${NEW_VERSION}/g" charts/kusk-gateway-api/Chart.yaml
- name: Lint the chart
run: |
helm lint charts/kusk-gateway-api
- name: Push updated chart
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git remote -v
git add .
git commit -m "automatically updated kusk-gateway related charts"
git push
- name: Slack Notification if the helm version bump succeeded
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: kusk
SLACK_COLOR: good
SLACK_ICON: https://github.githubassets.com/images/modules/site/features/actions-icon-actions.svg
SLACK_TITLE: Helm chart version bump succeeded :party_blob:!
SLACK_MESSAGE: "Kusk Gateway API chart version was bumped"
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> Kusk Gateway API"
notify_slack_if_helm_chart_bump_fails:
runs-on: ubuntu-latest
needs: helm_chart_version_bump
if: always() && (needs.helm_chart_version_bump.result == 'failure')
steps:
- name: Slack Notification if Helm Release action failed
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: kusk
SLACK_COLOR: ${{ needs.helm_chart_version_bump.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.githubassets.com/images/modules/site/features/actions-icon-actions.svg
SLACK_TITLE: Helm Chart version bump action failed :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> Kusk Gateway API"