-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (171 loc) · 6.72 KB
/
pre-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
name: Pre-release
on:
push:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
create-pre-release:
runs-on: ubuntu-latest
name: Build and push Docker image and create a new GitHub pre-release
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set environment variables
run: |
echo VERSION=$(cat VERSION).$GITHUB_RUN_NUMBER >> $GITHUB_ENV
echo BASE_IMAGE_NAME=$REGISTRY/$(echo ${GITHUB_REPOSITORY,,}) >> $GITHUB_ENV
echo COMMITED_AT=$(git show -s --format=%cI `git rev-parse HEAD`) >> $GITHUB_ENV
echo REVISION=$(git rev-parse --short HEAD) >> $GITHUB_ENV
- name: Collect Docker image metadata (api-legacy)
id: meta-api-legacy
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-api-legacy
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=GeoWerkstatt GmbH <[email protected]>
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (api)
id: meta-api
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-api
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=GeoWerkstatt GmbH <[email protected]>
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (client)
id: meta-client
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-client
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=GeoWerkstatt GmbH <[email protected]>
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (view-sync)
id: meta-view-sync
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-view-sync
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=GeoWerkstatt GmbH <[email protected]>
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (extern-sync)
id: meta-extern-sync
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-extern-sync
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=v${{ env.VERSION }}
org.opencontainers.image.maintainer=GeoWerkstatt GmbH <[email protected]>
flavor: |
latest=false
tags: |
type=edge
type=semver,pattern=v{{version}},value=${{ env.VERSION }}
- name: Log in to the GitHub container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image (api-legacy)
uses: docker/build-push-action@v5
with:
context: ./src/api-legacy
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-api-legacy.outputs.tags }}
labels: ${{ steps.meta-api-legacy.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-api-legacy:edge
cache-to: type=inline
- name: Build and push Docker image (api)
uses: docker/build-push-action@v5
with:
context: ./src
file: ./src/api/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-api:edge
cache-to: type=inline
- name: Build and push Docker image (client)
uses: docker/build-push-action@v5
with:
context: ./src/client
target: deploy
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-client.outputs.tags }}
labels: ${{ steps.meta-client.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-client:edge
cache-to: type=inline
- name: Build and push Docker image (view-sync)
uses: docker/build-push-action@v5
with:
context: ./src/view-sync
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-view-sync.outputs.tags }}
labels: ${{ steps.meta-view-sync.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-view-sync:edge
cache-to: type=inline
- name: Build and push Docker image (extern-sync)
uses: docker/build-push-action@v5
with:
context: ./src
file: ./src/extern-sync/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-extern-sync.outputs.tags }}
labels: ${{ steps.meta-extern-sync.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-extern-sync:edge
cache-to: type=inline
- name: Create GitHub pre-release
run: |
gh api \
--method POST \
--header "Accept: application/vnd.github+json" \
/repos/${GITHUB_REPOSITORY}/releases \
-f tag_name='v${{ env.VERSION }}' \
-f target_commitish='main' \
-f name='${{ env.VERSION }}' \
-F prerelease=true \