This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
219 lines (183 loc) · 6.72 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
name: release
on:
push:
branches:
- master
jobs:
release-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 14
- name: Cache Node.js modules
id: cache
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache hit
run: echo ${{ steps.cache.outputs.cache-hit }}
- name: Install dependencies
run: npm ci
env:
SKIP_BUILD: true
- name: Lint
run: npm run lint -- --no-fix
release-semantic:
needs: release-test
runs-on: ubuntu-latest
outputs:
published: ${{ steps.release.outputs.published }}
release-version: ${{ steps.release.outputs.release-version }}
release-version-major: ${{ steps.release.outputs.release-version-major }}
release-version-minor: ${{ steps.release.outputs.release-version-minor }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 14
- name: Cache Node.js modules
id: cache
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache hit
run: echo ${{ steps.cache.outputs.cache-hit }}
- name: Install dependencies
run: npm ci
env:
SKIP_BUILD: true
- name: Turnstyle
uses: softprops/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Semantic release
id: release
uses: ahmadnassri/[email protected]
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm_config_unsafe_perm: true
release-alias:
needs: release-semantic
if: needs.release-semantic.outputs.published == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
tag:
- v${{ needs.release-semantic.outputs.release-version-major }}
- v${{ needs.release-semantic.outputs.release-version-major }}.${{ needs.release-semantic.outputs.release-version-minor }}
steps:
- name: Recreate tag
uses: actions/[email protected]
with:
script: |
const tag = 'tags/${{ matrix.tag }}';
const repo = {
owner: context.repo.owner,
repo: context.repo.repo
};
await github.git.deleteRef({ ...repo, ref: tag }).catch(() => {});
await github.git.createRef({ ...repo, ref: `refs/${tag}` , sha: process.env.GITHUB_SHA });
release-docker:
needs: release-semantic
if: needs.release-semantic.outputs.published == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile
docker-image: ${{ github.event.repository.full_name }}
- dockerfile: Dockerfile.web
docker-image: ${{ github.event.repository.full_name }}web
steps:
- name: Checkout
uses: actions/[email protected]
- name: Prepare
id: prep
run: |
echo ::set-output name=build-date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: latest
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Get platforms
uses: actions/[email protected]
id: platforms
env:
DOCKER_CLI_EXPERIMENTAL: enabled
with:
result-encoding: string
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/getDockerPlatforms.js`)
return script("${{ matrix.dockerfile }}", "${{ steps.buildx.outputs.platforms }}");
- name: Platforms
run: echo ${{ steps.platforms.outputs.result }}
- name: Cache Docker layers
uses: actions/[email protected]
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-docker-${{ matrix.dockerfile }}-
${{ runner.os }}-docker-
- name: Cache hit
run: echo ${{ steps.cache.outputs.cache-hit }}
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker-build
uses: docker/build-push-action@v2
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./${{ matrix.dockerfile}}
platforms: ${{ steps.platforms.outputs.result }}
tags: |
${{ matrix.docker-image }}:latest
${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version }}
${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version-major }}.${{ needs.release-semantic.outputs.release-version-minor }}
${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version-major }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
build-args: |
VERSION=${{ needs.release-semantic.outputs.release-version }}
BUILD_DATE=${{ steps.prep.outputs.build-date }}
REVISION=${{ github.sha }}
- name: Update repo description
uses: peter-evans/[email protected]
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKERHUB_REPOSITORY: ${{ matrix.docker-image }}
- name: Inspect
run: |
docker buildx imagetools inspect ${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version }}
- name: Image digest
run: echo ${{ steps.docker-build.outputs.digest }}
- name: Dump context
if: always()
uses: crazy-max/[email protected]