-
Notifications
You must be signed in to change notification settings - Fork 10
237 lines (219 loc) · 8.73 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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
version:
name: Set Version from git ref
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- id: version
run: echo "::set-output name=version::$(sed 's#^refs/tags/\(.*\)#\1#' <<< '${{ github.ref }}')"
binaries:
name: Binaries
runs-on: ubuntu-latest
needs: version
env:
VERSION: ${{ needs.version.outputs.version }}
BUILD_DATE: '$$(date +%Y-%m-%d-%H:%M)'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build Binaries
run: |
make release-artifacts
- name: Generate Release Notes
run: scripts/release-notes.sh $VERSION > release-notes.md
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: ${{ env.VERSION }}
name: ${{ env.VERSION }}
bodyFile: "release-notes.md"
prerelease: ${{ contains(env.VERSION, '-alpha.') || contains(env.VERSION, '-beta.') || contains(env.VERSION, '-rc.') || contains(env.VERSION, '-nightly.') }}
- name: Upload macOS (amd64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-amd64.zip"
asset_name: "fsm-${{ env.VERSION }}-darwin-amd64.zip"
asset_content_type: application/zip
- name: Upload macOS (amd64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-amd64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-darwin-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload macOS (arm64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-arm64.zip"
asset_name: "fsm-${{ env.VERSION }}-darwin-arm64.zip"
asset_content_type: application/zip
- name: Upload macOS (arm64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-darwin-arm64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-darwin-arm64.tar.gz"
asset_content_type: application/gzip
- name: Upload Linux (amd64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-amd64.zip"
asset_name: "fsm-${{ env.VERSION }}-linux-amd64.zip"
asset_content_type: application/zip
- name: Upload Linux (amd64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-amd64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-linux-amd64.tar.gz"
asset_content_type: application/gzip
- name: Upload Linux (arm64).zip
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-arm64.zip"
asset_name: "fsm-${{ env.VERSION }}-linux-arm64.zip"
asset_content_type: application/zip
- name: Upload Linux (arm64).tar.gz
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "_dist/fsm-${{ env.VERSION }}-linux-arm64.tar.gz"
asset_name: "fsm-${{ env.VERSION }}-linux-arm64.tar.gz"
asset_content_type: application/gzip
- name: Upload Checksums
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: _dist/sha256sums.txt
asset_name: sha256sums.txt
asset_content_type: text/plain
images:
name: Docker Images
runs-on: ubuntu-latest
needs: version
env:
VERSION: ${{ needs.version.outputs.version }}
BUILD_DATE_VAR: 'github.com/flomesh-io/fsm/pkg/version.BuildDate'
BUILD_VERSION_VAR: 'github.com/flomesh-io/fsm/pkg/version.Version'
BUILD_GITCOMMIT_VAR: 'github.com/flomesh-io/fsm/pkg/version.GitCommit'
strategy:
matrix:
id: [ "curl", "sidecar-init", "controller", "injector", "connector", "crds", "bootstrap", "preinstall", "healthcheck", "interceptor", "ingress", "gateway" ]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Login to DockerHub
uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.RELEASE_DOCKER_USER }}
password: ${{ secrets.RELEASE_DOCKER_PASS }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Package Helm Charts
run: make charts-tgz
- name: Docker meta - ${{ matrix.id }}
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v5.5.1
with:
images: ${{ secrets.RELEASE_REGISTRY }}/fsm-${{ matrix.id }}
tags: |
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=sha,format=short
flavor: |
latest=auto
- name: Get Build Info
run: |
echo "BUILD_DATE=$(date +%Y-%m-%d-%H:%M)" >> $GITHUB_ENV
echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Build and Push - ${{ matrix.id }}
uses: docker/build-push-action@v6.0.1
with:
context: .
file: ./dockerfiles/Dockerfile.fsm-${{ matrix.id }}
platforms: linux/amd64,linux/arm64
build-args: |
GO_VERSION=1.22
LDFLAGS=-X ${{ env.BUILD_DATE_VAR }}=${{ env.BUILD_DATE }} -X ${{ env.BUILD_VERSION_VAR }}=${{ env.VERSION }} -X ${{ env.BUILD_GITCOMMIT_VAR }}=${{ env.GIT_SHA }} -s -w
DISTROLESS_TAG=nonroot
push: ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
demo-images:
name: Demo Docker Images
runs-on: ubuntu-latest
needs: version
strategy:
matrix:
id: [ "bookbuyer", "bookthief", "bookstore", "bookwarehouse", "tcp-echo-server", "tcp-client" ]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Login to DockerHub
uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.RELEASE_DOCKER_USER }}
password: ${{ secrets.RELEASE_DOCKER_PASS }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Docker meta - ${{ matrix.id }}
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v5.5.1
with:
images: ${{ secrets.RELEASE_REGISTRY }}/fsm-demo-${{ matrix.id }}
tags: |
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=sha,format=short
flavor: |
latest=auto
- name: Build and Push - ${{ matrix.id }}
uses: docker/build-push-action@v6.0.1
with:
context: .
file: ./dockerfiles/Dockerfile.demo
platforms: linux/amd64,linux/arm64
build-args: |
GO_VERSION=1.22
BINARY=${{ matrix.id }}
push: ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}