-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (168 loc) · 6.59 KB
/
publish-release-artifacts.yaml
File metadata and controls
177 lines (168 loc) · 6.59 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
name: Publish Release Artifacts
on:
release:
types:
# This triggers on both prerelease and release
- published
jobs:
publish-release-artifacts:
runs-on: ubuntu-latest
# based on: https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers#running-jobs-directly-on-the-runner-machine
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Get tag
run: |
echo "TAG=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV"
- uses: bufbuild/buf-setup-action@v1
- name: Push to BSR
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
# Due to this issue (https://github.com/bufbuild/buf/issues/1621) in buf, no tag is created if the proto files are not changed
# To keep the BSR tags in sync with our git repo, we manually add every tag
# Furthermore, the buf_dependency_version needs to be constructed from the latest commit that is tagged, as that's how the BSR SDK dependency versions are constructed
run: |
cd protos
buf_commit_hash_or_empty=$(buf push)
buf_commit_hash=$([[ ${buf_commit_hash_or_empty} = "" ]] && buf beta registry commit list --page-size 1 --reverse --format json buf.build/getstrm/pace:main | jq -r '.results[0].commit' || echo "$buf_commit_hash_or_empty")
buf beta registry tag create "buf.build/getstrm/pace:${buf_commit_hash}" ${{ env.TAG }}
buf_dependency_version=$(buf alpha sdk maven-version --module=buf.build/getstrm/pace:${{ env.TAG }} --plugin=buf.build/protocolbuffers/java:v24.4 | sed "s/24.4.0.1.//")
echo "BUF_DEPENDENCY_VERSION=${buf_dependency_version}" >> "$GITHUB_ENV"
- name: Generate JSON Schema
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
run: |
cd protos
buf generate
- name: Copy JSON Schema
run: |
make copy-json-schema-to-resources
# JVM artifacts
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- run: ./gradlew build prepareForDocker -PciBuild -PgeneratedBufDependencyVersion=${{ env.BUF_DEPENDENCY_VERSION }}
- name: Upload
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
run: |
tag_name="${GITHUB_REF##*/}"
mkdir artifacts
find . -type d -name "libs" -not -path "./core/*" -not -path "./build/*" | xargs -I{} find "{}" -type f -name "*.jar" | xargs -I{} sh -c 'cp "{}" "./artifacts/$(echo {} | cut -d / -f 2).jar"'
gh release upload "$tag_name" $(find artifacts -type f -name "*.jar" -printf "%p ")
# We tar the artifacts to maintain permissions, see https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: Tar artifacts
run: tar -cvf artifacts.tar **/build/libs **/build/docker protos
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts.tar
build-server-image:
runs-on: ubuntu-latest
needs: [publish-release-artifacts]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
- name: Untar artifacts
run: tar -xvf artifacts.tar
- uses: bufbuild/buf-setup-action@v1
# Build container image
- name: "Generate Proto Filedescriptor"
# Normally generated in the Gradle prepareForDocker step, but the ciBuild flag disables that
run: |
cd protos
mkdir -p ../server/build/docker
buf build -o ../server/build/docker/descriptor.binpb
# Container artifact
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.BOT_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: "ghcr.io/getstrm/pace"
tags: |
type=raw,value=latest
type=raw,value=latest-alpha
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ env.TAG }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.TAG }}
type=semver,pattern={{major}},value=${{ env.TAG }}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: server/build/docker
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-dbt-image:
runs-on: ubuntu-latest
needs: [publish-release-artifacts]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
- name: Untar artifacts
run: tar -xvf artifacts.tar
# Container artifact
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.BOT_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: "ghcr.io/getstrm/pace-dbt"
tags: |
type=raw,value=latest
type=raw,value=latest-alpha
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ env.TAG }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.TAG }}
type=semver,pattern={{major}},value=${{ env.TAG }}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: dbt/build/docker
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}