-
Notifications
You must be signed in to change notification settings - Fork 7
149 lines (132 loc) · 4.45 KB
/
release.yml
File metadata and controls
149 lines (132 loc) · 4.45 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch: {}
permissions:
contents: write
packages: write
env:
BROWSER_UPSTREAM: ghcr.io/browserless/chromium
BROWSER_VERSION: v2.44.0
jobs:
mirror-browser:
name: mirror-browser
runs-on: ubuntu-latest
steps:
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull, tag, and push browser image
run: |
src="${BROWSER_UPSTREAM}:${BROWSER_VERSION}"
dst="ghcr.io/${GITHUB_REPOSITORY@L}-browser"
docker pull "$src"
docker tag "$src" "$dst:${BROWSER_VERSION}"
docker tag "$src" "$dst:latest"
docker push "$dst:${BROWSER_VERSION}"
docker push "$dst:latest"
release:
name: publish-${{ matrix.image.name }}
needs: mirror-browser
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- name: web
dockerfile: Dockerfile
image_suffix: -web
- name: collector
dockerfile: Dockerfile.collector
image_suffix: -collector
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Build release bundle
env:
APP_VERSION: ${{ github.ref_name }}
run: npm run build
- name: Archive dist
if: matrix.image.name == 'web'
run: |
tar -czf euosint-dist-${GITHUB_REF_NAME}.tar.gz dist
shasum -a 256 euosint-dist-${GITHUB_REF_NAME}.tar.gz > euosint-dist-${GITHUB_REF_NAME}.tar.gz.sha256
- name: Prepare image name
id: image
run: echo "name=ghcr.io/${GITHUB_REPOSITORY@L}${{ matrix.image.image_suffix }}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.image.outputs.name }}
tags: |
type=raw,value=${{ github.ref_name }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest
- name: Build and push image (attempt 1)
id: build_push_1
continue-on-error: true
uses: docker/build-push-action@v6
with:
context: .
file: ./${{ matrix.image.dockerfile }}
push: true
provenance: false
build-args: |
APP_VERSION=${{ github.ref_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=release-${{ matrix.image.name }}
cache-to: type=gha,mode=max,scope=release-${{ matrix.image.name }}
- name: Build and push image (attempt 2 on transient failure)
if: steps.build_push_1.outcome == 'failure'
uses: docker/build-push-action@v6
with:
context: .
file: ./${{ matrix.image.dockerfile }}
push: true
provenance: false
build-args: |
APP_VERSION=${{ github.ref_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=release-${{ matrix.image.name }}
cache-to: type=gha,mode=max,scope=release-${{ matrix.image.name }}
- name: Publish GitHub release
if: matrix.image.name == 'web'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" \
"euosint-dist-${GITHUB_REF_NAME}.tar.gz" \
"euosint-dist-${GITHUB_REF_NAME}.tar.gz.sha256" \
--clobber
else
gh release create "${GITHUB_REF_NAME}" \
"euosint-dist-${GITHUB_REF_NAME}.tar.gz" \
"euosint-dist-${GITHUB_REF_NAME}.tar.gz.sha256" \
--generate-notes
fi