-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (163 loc) · 7.27 KB
/
release.yml
File metadata and controls
182 lines (163 loc) · 7.27 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
178
179
180
181
182
name: Build and upload Docker image
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io/${{ github.repository_owner }}
jobs:
release-please:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
concurrency:
group: release-please-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
outputs:
graph_tally_aggregator: ${{ steps.release-please.outputs['crates/bin/aggregator--tag_name'] }}
graph_tally_escrow_manager: ${{ steps.release-please.outputs['crates/bin/escrow_manager--tag_name'] }}
steps:
- name: Release please
id: release-please
uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
prepare:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.set.outputs.targets }}
steps:
- id: set
run: echo 'targets=["graph_tally_aggregator","graph_tally_escrow_manager"]' >> $GITHUB_OUTPUT
build:
name: Build ${{ matrix.target }} (${{ matrix.platform }})
needs: [prepare, release-please]
if: always() && needs.prepare.result == 'success' && (needs.release-please.result == 'success' || needs.release-please.result == 'skipped')
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.prepare.outputs.targets) }}
platform: [linux/amd64, linux/arm64]
include:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
packages: write
steps:
- name: Prepare platform pair
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Log in to the Container registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker labels
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: ${{ env.REGISTRY }}/${{ matrix.target }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: ./
file: docker/Dockerfile.${{ matrix.target }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.target }}-${{ env.PLATFORM_PAIR }}
cache-to: type=gha,mode=max,scope=${{ matrix.target }}-${{ env.PLATFORM_PAIR }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ matrix.target }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
- name: Export digest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
with:
name: digests-${{ matrix.target }}-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Merge ${{ matrix.target }} into multi-arch manifest
needs: [prepare, release-please, build]
if: |
!cancelled()
&& needs.build.result == 'success'
&& (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.prepare.outputs.targets) }}
runs-on: ubuntu-latest
permissions:
packages: write
steps:
# When release-please is skipped (workflow_dispatch, or no releasable commits) VERSION is empty;
# meta.outputs.version then falls back to the branch/sha tag, which is intentional.
- name: Extract version from tag
id: extract_version
run: |
TAG_NAME="${{ needs.release-please.outputs[matrix.target] }}"
if [[ "$TAG_NAME" =~ ^${{ matrix.target }}-(.*)$ ]]; then
VERSION="${BASH_REMATCH[1]}"
else
VERSION=""
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ matrix.target }}-*
merge-multiple: true
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker tags
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: ${{ env.REGISTRY }}/${{ matrix.target }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{major}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern=v{{version}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern=v{{major}}.{{minor}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern=v{{major}}.{{minor}}.{{patch}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern=v{{major}},value=${{ steps.extract_version.outputs.version }}
type=sha,enable=true
# Glob `*` expands to digest-named files written by the build job's Export digest step.
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ matrix.target }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ matrix.target }}:${{ steps.meta.outputs.version }}