-
Notifications
You must be signed in to change notification settings - Fork 14
166 lines (144 loc) · 4.91 KB
/
Copy pathrelease-docker.yml
File metadata and controls
166 lines (144 loc) · 4.91 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
name: "Release Docker images"
on:
workflow_dispatch:
push:
branches: ["main"]
tags:
- "v*"
env:
REGISTRY_IMAGE: sourcegraph/scip-clang
jobs:
build-binaries:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04-32core-graph-team-amd64
platform: linux/amd64
binary-name: scip-clang-x86_64-linux
- os: ubuntu-24.04-32core-graph-team-arm64
platform: linux/arm64
binary-name: scip-clang-arm64-linux
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/setup-bazel@0.14.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}-${{ matrix.binary-name }}
repository-cache: true
- name: Build binary
run: bazel build //indexer:scip-clang --config release
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: bazel-bin/indexer/scip-clang
name: ${{ matrix.binary-name }}
if-no-files-found: error
build-docker:
needs: [build-binaries]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
platform: linux/amd64
binary-name: scip-clang-x86_64-linux
- os: ubuntu-22.04-arm
platform: linux/arm64
binary-name: scip-clang-arm64-linux
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download pre-built binary
uses: actions/download-artifact@v4
with:
name: ${{ matrix.binary-name }}
path: /tmp/binary
- run: cp /tmp/binary/scip-clang ./scip-clang && ls -l ./scip-clang
- name: Build and push by digest
id: build-images
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ env.REGISTRY_IMAGE }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build-images.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge-docker:
runs-on: ubuntu-latest
needs: [build-docker]
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Push SHA tag (workflow_dispatch only)
if: github.event_name == 'workflow_dispatch'
working-directory: ${{ runner.temp }}/digests
run: |
SHORT_SHA="sha-$(echo ${{ github.sha }} | cut -c1-7)"
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:$SHORT_SHA \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Snapshot metadata
if: github.ref == 'refs/heads/main'
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=latest-snapshot
- name: Tag metadata
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=latest
type=raw,value=${{ env.PATCH }}
type=raw,value=${{ env.MINOR }}
type=raw,value=${{ env.MAJOR }}
- name: Create manifest list and push
if: github.event_name != 'workflow_dispatch'
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)