-
Notifications
You must be signed in to change notification settings - Fork 3
137 lines (133 loc) · 4.02 KB
/
.binaries.yml
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
# reusable workflow
name: .binaries
on:
workflow_call:
inputs:
target:
type: string
required: true
repo:
type: string
required: true
artifact_key:
type: string
required: true
cache_prefix:
type: string
required: true
candidates_key:
type: string
required: true
refs:
type: string
required: true
last_days:
type: string
default: 7
last_releases:
type: string
default: 3
env:
GO_VERSION: 1.23
SETUP_BUILDX_VERSION: latest
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
BUILDKIT_CACHE_REPO: moby/buildkit-bench-cache
jobs:
prepare:
runs-on: ubuntu-24.04
outputs:
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
-
name: Set includes
id: set
run: |
go run -mod=vendor ./cmd/refcandidates \
--repo "${{ inputs.repo }}" \
--refs "${{ inputs.refs }}" \
--last-days "${{ inputs.last_days }}" \
--last-releases "${{ inputs.last_releases }}" \
--file-output ./bin/${{ inputs.candidates_key }}.json \
--gha-output includes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: List candidates
run: |
jq . ./bin/${{ inputs.candidates_key }}.json
-
name: Upload candidates
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.candidates_key }}
path: ./bin/${{ inputs.candidates_key }}.json
if-no-files-found: error
retention-days: 7
build:
runs-on: ubuntu-24.04
needs:
- prepare
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare.outputs.includes) }}
steps:
-
name: Prepare
run: |
case ${{ inputs.target }} in
buildkit)
echo "BUILDKIT_REPO=${{ inputs.repo }}" >> $GITHUB_ENV
echo "BUILDKIT_REFS=${{ matrix.ref }}" >> $GITHUB_ENV
;;
buildx)
echo "BUILDX_REPO=${{ inputs.repo }}" >> $GITHUB_ENV
echo "BUILDX_REFS=${{ matrix.ref }}" >> $GITHUB_ENV
;;
esac
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build
uses: docker/bake-action@v6
with:
targets: ${{ inputs.target }}-build
provenance: false
set: |
*.output=./bin/binaries/${{ matrix.name }}
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:${{ inputs.cache_prefix }}-${{ matrix.commit }}
*.cache-to=type=registry,ignore-error=true,mode=max,ref=${{ env.BUILDKIT_CACHE_REPO }}:${{ inputs.cache_prefix }}-${{ matrix.commit }}
*.cache-to=type=registry,ignore-error=true,mode=max,ref=${{ env.BUILDKIT_CACHE_REPO }}:${{ inputs.cache_prefix }}-${{ matrix.ref }}
-
# https://github.com/actions/upload-artifact/?tab=readme-ov-file#permission-loss
name: Tar binaries
working-directory: ./bin/binaries
run: tar -czvf ../binaries-${{ matrix.name }}.tar.gz *
-
name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_key }}-${{ matrix.name }}
path: ./bin/binaries-${{ matrix.name }}.tar.gz
if-no-files-found: error
retention-days: 7