-
-
Notifications
You must be signed in to change notification settings - Fork 5
228 lines (182 loc) · 7.36 KB
/
Copy pathbuild.yml
File metadata and controls
228 lines (182 loc) · 7.36 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Build
on:
push:
branches:
- main
- release/**
pull_request:
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
platform: amd64
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04-arm
platform: arm64
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y llvm
curl -sL https://sentry.io/get-cli/ | bash
- name: Install Rust Toolchain
run: |
rustup toolchain install stable --profile minimal --target ${{ matrix.target }} --no-self-update
- name: Install protoc
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Ensure a clean build on release, use caches when building main.
- uses: swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
with:
key: ${{ github.job }}
- name: Build Binary
run: |
cargo build --release --locked --target=${{ matrix.target }} --bin objectstore --features profiling
cp target/${{ matrix.target }}/release/objectstore ./objectstore
- name: Split Debug Info
run: |
llvm-objcopy --only-keep-debug objectstore objectstore.debug
llvm-objcopy --strip-debug --strip-unneeded objectstore
llvm-objcopy --add-gnu-debuglink objectstore.debug objectstore
sentry-cli difutil bundle-sources objectstore.debug
zip objectstore-debug.zip objectstore.debug
mkdir -p /tmp/artifacts/${{ matrix.platform }}
mv objectstore-debug.zip objectstore.src.zip /tmp/artifacts/${{ matrix.platform }}/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Build Image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
platforms: linux/${{ matrix.platform }}
tags: ${{ matrix.platform }}
outputs: type=docker,dest=/tmp/artifacts/objectstore-${{ matrix.platform }}.tar
push: false
- name: Test Image
run: |
docker load --input /tmp/artifacts/objectstore-${{ matrix.platform }}.tar
docker run --rm ${{ matrix.platform }} version | grep -q '^objectstore@'
- name: Upload Artifacts
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: objectstore-${{ matrix.platform }}
path: /tmp/artifacts/
assemble-ghcr:
name: Publish to GHCR
runs-on: ubuntu-latest
needs: [build]
# Intentionally never publish on pull requests
if: ${{ github.event_name != 'pull_request' }}
permissions:
packages: write
env:
REGISTRY: ghcr.io/getsentry/objectstore
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN"
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- &download
name: Download Images
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
pattern: objectstore-*
path: /tmp
merge-multiple: true
- &assemble
name: Push to GitHub Container Registry
run: |
for PLATFORM in amd64 arm64; do
docker load --input /tmp/objectstore-$PLATFORM.tar
docker tag $PLATFORM "$REGISTRY:$GITHUB_SHA-$PLATFORM"
docker push "$REGISTRY:$GITHUB_SHA-$PLATFORM"
done
# Push nightly on main branch - releases are tagged by craft.
TAGS="$GITHUB_SHA"
if [[ "$GITHUB_REF" != refs/heads/release/* ]]; then
TAGS="$TAGS nightly"
fi
for TAG in $TAGS; do
docker manifest create "$REGISTRY:$TAG" \
--amend "$REGISTRY:$GITHUB_SHA-amd64" \
--amend "$REGISTRY:$GITHUB_SHA-arm64"
docker manifest push "$REGISTRY:$TAG"
done
assemble-gcr:
name: Publish to GCR
runs-on: ubuntu-latest
needs: [build]
# Intentionally never publish on pull requests
if: ${{ github.event_name != 'pull_request' }}
permissions:
id-token: write
env:
REGISTRY: us-docker.pkg.dev/sentryio/objectstore-mr/image
steps:
- name: Google Auth
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool
service_account: gha-gcr-push@sac-prod-sa.iam.gserviceaccount.com
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db" # v3.0.1
with:
version: ">= 390.0.0"
- name: Configure docker
run: gcloud auth configure-docker us-docker.pkg.dev
- *download
- *assemble
gocd-artifacts:
name: Upload Build Artifacts for GoCD
runs-on: ubuntu-latest
needs: [build]
# Intentionally never publish on pull requests
if: ${{ github.event_name != 'pull_request' }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Google Auth
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool
service_account: gha-gcr-push@sac-prod-sa.iam.gserviceaccount.com
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db" # v3.0.1
with:
version: ">= 390.0.0"
- name: Download Artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
pattern: objectstore-*
path: /tmp
merge-multiple: true
- name: Upload artifacts
env:
# the upload SA has no delete perms; disable parallel composite uploads
# since their chunk cleanup would fail on delete
CLOUDSDK_STORAGE_PARALLEL_COMPOSITE_UPLOAD_ENABLED: false
run: |
docker load --input /tmp/objectstore-amd64.tar
docker run --rm amd64 version > /tmp/release-name
gcloud storage cp --no-clobber /tmp/release-name \
"gs://dicd-team-devinfra-cd--objectstore/deployment-assets/$GITHUB_SHA/"
for PLATFORM in amd64 arm64; do
gcloud storage cp --no-clobber \
"/tmp/$PLATFORM/objectstore-debug.zip" \
"/tmp/$PLATFORM/objectstore.src.zip" \
"gs://dicd-team-devinfra-cd--objectstore/deployment-assets/$GITHUB_SHA/$PLATFORM/"
done