-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (90 loc) · 3.1 KB
/
publish-release-artifacts.yaml
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
name: Publish Release Artifacts
on:
release:
types:
# This triggers on both prerelease and release
- published
jobs:
buf-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1
- name: Get tag
run: |
echo "TAG=${GITHUB_REF#refs/*/}"
- name: Push to BSR
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
run: buf push --tag ${{ env.TAG }}
container-build:
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 }}
run: |
buf_commit_hash=$(buf push --tag ${{ env.TAG }})
buf_commit_hash_short=$(echo $buf_commit_hash | cut -c1-12)
echo "BUF_COMMIT_HASH=${buf_commit_hash_short}" >> "$GITHUB_ENV"
# JVM artifact
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@v2
- name: "Generate Proto Filedescriptor"
# Normally generated in the Gradle prepareForDocker step, but the ciBuild flag disables that
run: |
cd protos
mkdir -p ../app/build/docker
buf build -o ../app/build/docker/descriptor.binpb
- run: ./gradlew prepareForDocker -PciBuild -PgeneratedBufDependencyVersion=00000000000000.${{ env.BUF_COMMIT_HASH }}
# Container artifact
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: "ghcr.io/getstrm/pace"
tags: |
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@v5
with:
context: app/build/docker
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}