-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (211 loc) · 7.53 KB
/
release.yml
File metadata and controls
219 lines (211 loc) · 7.53 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
name: Release
on: workflow_dispatch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
env:
GH_ACTIONS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
# get enough commits to hopefully allow goreleaser to generate a proper
# changelog since the last release
fetch-depth: 100
- name: Setup Go Module Access Token
run: |
git config --global url."https://x-access-token:$GH_ACTIONS_TOKEN@github.com/fastcat/gdev".insteadOf https://github.com/fastcat/gdev
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.work'
cache-dependency-path: |
go.mod
**/go.mod
- name: Tag Release
id: semrel
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
force-bump-patch-version: true
- name: Tag Submodules
run: |
set -xe
ver="v${{ steps.semrel.outputs.version }}"
# semrel-created tag will have only been created on the remote, fetch it
git fetch origin "refs/tags/${ver}:refs/tags/${ver}"
go tool mage -v tagSubModules "${ver}"
git push origin $(git tag -l "*/${ver}")
outputs:
version: "${{ steps.semrel.outputs.version }}"
publish-e-s-svc1:
needs: release
runs-on: ubuntu-latest
env:
GH_ACTIONS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.work'
cache-dependency-path: |
go.mod
**/go.mod
- name: Set up ko
uses: ko-build/setup-ko@v0.9
- name: Build & Publish svc1
# TODO: use mage for this so it can pick up all the defined builds automatically
# make sure to overwrite all the labels from the chainguard base image
run: |
# DRY?
labels=(
org.opencontainers.image.authors="fastcat"
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.url=${{ github.repositoryUrl }}/tree/${{ github.sha }}/examples/stack/svc1
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses="Apache-2.0"
org.opencontainers.image.version="${{ needs.release.outputs.version }}"
org.opencontainers.image.vendor="fastcat"
)
labelargs=()
for label in "${labels[@]}"; do
labelargs+=(--image-label "$label" --image-annotation "$label")
done
ko build \
--base-import-paths \
"${labelargs[@]}" \
--tags "latest,${{ needs.release.outputs.version }}" \
./examples/stack/svc1
publish-e-s-svc2:
needs: release
runs-on: ubuntu-latest
env:
GH_ACTIONS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-tags: true
- name: Set up NodeJS
uses: actions/setup-node@v6
with:
node-version: "lts/*"
# TODO: cache doesn't support rush
cache-dependency-path: examples/stack/svc2/common/config/rush/pnpm-lock.yaml
- name: "Build svc2"
working-directory: examples/stack/svc2
run: |
set -xe
node common/scripts/install-run-rush.js install
node common/scripts/install-run-rush.js build --verbose
node common/scripts/install-run-rush.js deploy
- name: Docker Login
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish svc2
uses: docker/build-push-action@v7
with:
context: examples/stack/svc2
file: examples/stack/svc2/app/Dockerfile
push: true
tags: |
ghcr.io/fastcat/gdev/svc2:${{ needs.release.outputs.version }}
ghcr.io/fastcat/gdev/svc2:latest
labels: |
org.opencontainers.image.authors=fastcat
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/examples/stack/svc2
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses="Apache-2.0"
org.opencontainers.image.version="${{ needs.release.outputs.version }}"
org.opencontainers.image.vendor=fastcat
annotations: |
org.opencontainers.image.authors=fastcat
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/examples/stack/svc2
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses="Apache-2.0"
org.opencontainers.image.version="${{ needs.release.outputs.version }}"
org.opencontainers.image.vendor=fastcat
publish-e-fs-ent-blog:
needs: release
runs-on: ubuntu-latest
env:
GH_ACTIONS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.work'
cache-dependency-path: |
go.mod
**/go.mod
- name: Set up ko
uses: ko-build/setup-ko@v0.9
- name: "Build & Publish ent-blog svc"
# TODO: use mage for this so it can pick up all the defined builds automatically
# make sure to overwrite all the labels from the chainguard base image
run: |
# DRY?
labels=(
org.opencontainers.image.authors="fastcat"
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/examples/full-stack/ent-blog
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses="Apache-2.0"
org.opencontainers.image.version="${{ needs.release.outputs.version }}"
org.opencontainers.image.vendor="fastcat"
)
labelargs=()
for label in "${labels[@]}"; do
labelargs+=(--image-label "$label" --image-annotation "$label")
done
ko build \
--base-import-paths \
"${labelargs[@]}" \
--tags "latest,${{ needs.release.outputs.version }}" \
./examples/full-stack/ent-blog
publish-e-gdev-deb:
needs: release
runs-on: ubuntu-latest
env:
GH_ACTIONS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.work'
cache-dependency-path: |
go.mod
**/go.mod
- name: Publish gdev example
uses: goreleaser/goreleaser-action@v7
with:
workdir: examples/gdev
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# this is always a release build
PKGSUFFIX: ""