generated from wuespace/telestion-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (197 loc) · 7.38 KB
/
publish-client.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
name: Publish Client Binaries
# Events that trigger this workflow
on:
workflow_run:
workflows: ["Release"]
types: [completed]
jobs:
update:
name: "Update package version"
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
defaults:
run:
working-directory: ./client
steps:
- name: Checkout 📥
uses: actions/[email protected]
- name: Download build environment 📥
uses: dawidd6/[email protected]
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: build-env
path: ${{ github.workspace }}
- name: Import environment ⛓
shell: bash
run: cat "${GITHUB_WORKSPACE}/.build-env" >> $GITHUB_ENV
- name: Fail on skipped release
run: test "$SKIPPED" = "false"
env:
SKIPPED: ${{ env.skipped }}
- name: Update package version
run: |
sed -i 's/"version": "[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+"/"version": "'"$VERSION"'"/gm' package.json
env:
VERSION: ${{ env.version }}
- name: Commit changes
continue-on-error: true
run: |
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "chore(client): Bump package version"
git push
publish-docker-image:
name: "Build and push to Docker registry"
runs-on: ubuntu-latest
needs: update
if: ${{ github.event.workflow_run.conclusion == 'success' }}
defaults:
run:
working-directory: ./client
steps:
- name: Checkout 📥
uses: actions/[email protected]
- name: Setup Node 💿
uses: actions/[email protected]
with:
node-version: 14
- name: Set up Docker Buildx ⬆
uses: docker/[email protected]
# Remove, when checkout error is resolved
# See https://github.com/actions/checkout/issues/439
- name: Pull latest changes
run: git pull origin main
# Remove, when setup-node action supports specifying the node version
- name: Install npm v7 ⬆
run: npm install --global npm@v7
- name: Download build environment 📥
uses: dawidd6/[email protected]
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: build-env
path: ${{ github.workspace }}
- name: Import environment ⛓
shell: bash
run: cat "${GITHUB_WORKSPACE}/.build-env" >> $GITHUB_ENV
- name: Extract semver numbers ⛓
run: |
echo "major=$(echo "$VERSION" | cut -d '.' -f 1 -)" >> $GITHUB_ENV
echo "minor=$(echo "$VERSION" | cut -d '.' -f 2 -)" >> $GITHUB_ENV
echo "patch=$(echo "$VERSION" | cut -d '.' -f 3 -)" >> $GITHUB_ENV
env:
VERSION: ${{ env.version }}
- name: Cache Docker layers ♻️
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Install development dependencies 📚
run: npm ci
- name: Build binaries 🗜
run: npm run build
# You may need to manage write and read access of GitHub Actions
# for this repository in the container settings.
#
# You can also use a personal access token (PAT) with the appropriate scopes.
#
# Please see:
# https://github.com/marketplace/actions/docker-login#github-container-registry
- name: Login to GitHub Container Registry 🛂
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image 🗜
id: docker_build
uses: docker/[email protected]
with:
context: "${{ github.workspace }}/client"
pull: true
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
tags: |
ghcr.io/${{ github.repository }}-client:latest
ghcr.io/${{ github.repository }}-client:${{ env.version }}
ghcr.io/${{ github.repository }}-client:${{ env.major }}.${{ env.minor }}
ghcr.io/${{ github.repository }}-client:${{ env.major }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
# Temporary fix for growing caches
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
#
# Please see:
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
- name: Move cache ♻️
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
publish:
name: "Build and publish for ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
needs: update
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
defaults:
run:
working-directory: ./client
steps:
- name: Checkout 📥
uses: actions/[email protected]
- name: Setup Node 💿
uses: actions/[email protected]
with:
node-version: 14
# Remove, when checkout error is resolved
# See https://github.com/actions/checkout/issues/439
- name: Pull latest changes
run: git pull origin main
# Remove, when setup-node action supports specifying the node version
- name: Install npm v7 ⬆
run: npm install --global npm@v7
- name: Download build environment 📥
uses: dawidd6/[email protected]
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: build-env
path: ${{ github.workspace }}
- name: Import environment ⛓
shell: bash
run: cat "${GITHUB_WORKSPACE}/.build-env" >> $GITHUB_ENV
- name: Install development dependencies 📚
run: npm ci
- name: Build binaries 🗜
run: npm run build
- name: Compress generated client build
if: ${{ env.skipped == 'false' && matrix.os == 'ubuntu-latest' }}
run: zip -r "${ARCHIVE}.zip" build
env:
ARCHIVE: telestion-project-daedalus2-client-build-${{ env.version }}
- name: Upload generated client build
if: ${{ env.skipped == 'false' && matrix.os == 'ubuntu-latest' }}
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.tag }}
file: ./client/telestion-project-daedalus2-client-build-*.zip
file_glob: true
- name: Upload release assets 🪡
if: ${{ env.skipped == 'false' }}
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.tag }}
file: ./client/dist/telestion-project-daedalus2*.*
file_glob: true