-
-
Notifications
You must be signed in to change notification settings - Fork 8
328 lines (272 loc) 路 10.1 KB
/
Copy pathbuild.yaml
File metadata and controls
328 lines (272 loc) 路 10.1 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: build
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
issues: write
id-token: write
attestations: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Login to GHCR
run: echo "${{ secrets.GORELEASER_GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser (build only)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
xbps:
runs-on: ubuntu-latest
needs: build
container:
image: ghcr.io/void-linux/void-glibc-full:latest
strategy:
fail-fast: true
matrix:
include:
- arch: x86_64
goreleaser_arch: amd64
- arch: i686
goreleaser_arch: 386
- arch: aarch64
goreleaser_arch: arm64
- arch: armv6l
goreleaser_arch: armv6
- arch: armv7l
goreleaser_arch: armv7
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Extract version
id: version
run: |
VERSION=$(cat dist/metadata.json | grep -o '"version":"[^"]*"' | cut -d'"' -f4)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Build XBPS package
run: |
xbps-install -Sy xbps
BINARY="dist/d4s_linux_${{ matrix.goreleaser_arch }}*/d4s"
if [ "${{ matrix.goreleaser_arch }}" = "armv6" ]; then
BINARY="dist/d4s_linux_arm_6/d4s"
elif [ "${{ matrix.goreleaser_arch }}" = "armv7" ]; then
BINARY="dist/d4s_linux_arm_7/d4s"
fi
PKG_DIR="pkg_${{ matrix.arch }}"
mkdir -p "${PKG_DIR}/usr/bin"
mkdir -p "${PKG_DIR}/usr/share/doc/d4s"
cp ${BINARY} "${PKG_DIR}/usr/bin/d4s"
chmod 755 "${PKG_DIR}/usr/bin/d4s"
cp dist/d4s_linux_${{ matrix.goreleaser_arch }}*/LICENSE* "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || true
cp dist/d4s_linux_${{ matrix.goreleaser_arch }}*/README* "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || true
cd "${PKG_DIR}"
xbps-create -A ${{ matrix.arch }} \
-n "d4s-${{ steps.version.outputs.version }}_1" \
-s "Master Docker like a pro, right from your terminal" \
-l "Apache-2.0" \
-m "jr-k <jrk@jierka.com>" \
-H "https://d4scli.io" \
.
mv *.xbps ../
- name: Upload XBPS artifact
uses: actions/upload-artifact@v4
with:
name: xbps-${{ matrix.arch }}
path: "*.xbps"
gentoo:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Extract version
id: version
run: |
VERSION=$(cat dist/metadata.json | grep -o '"version":"[^"]*"' | cut -d'"' -f4)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Generate ebuild
run: |
VERSION="${{ steps.version.outputs.version }}"
EBUILD_DIR="gentoo-overlay/app-misc/d4s"
mkdir -p "${EBUILD_DIR}"
cat > "${EBUILD_DIR}/d4s-${VERSION}.ebuild" << 'EBUILD_EOF'
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the Apache-2.0 license
EAPI=8
DESCRIPTION="Master Docker like a pro, right from your terminal"
HOMEPAGE="https://d4scli.io https://github.com/jr-k/d4s"
BASE_URI="https://github.com/jr-k/d4s/releases/download/v${PV}"
SRC_URI="
amd64? ( ${BASE_URI}/d4s_${PV}_linux_amd64.tar.gz )
arm64? ( ${BASE_URI}/d4s_${PV}_linux_arm64.tar.gz )
arm? ( ${BASE_URI}/d4s_${PV}_linux_armv7.tar.gz )
x86? ( ${BASE_URI}/d4s_${PV}_linux_x86.tar.gz )
"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
RDEPEND=""
DEPEND=""
S="${WORKDIR}"
QA_PREBUILT="usr/bin/d4s"
src_install() {
dobin d4s
dodoc README.md LICENSE
}
EBUILD_EOF
sed -i 's/^ //' "${EBUILD_DIR}/d4s-${VERSION}.ebuild"
mkdir -p gentoo-overlay/metadata
cat > gentoo-overlay/metadata/layout.conf << 'EOF'
masters = gentoo
auto-sync = false
EOF
sed -i 's/^ //' gentoo-overlay/metadata/layout.conf
mkdir -p gentoo-overlay/profiles
echo "gentoo-d4s" > gentoo-overlay/profiles/repo_name
- name: Upload gentoo overlay artifact
uses: actions/upload-artifact@v4
with:
name: gentoo-overlay
path: gentoo-overlay/
release:
runs-on: ubuntu-latest
needs: [build, xbps, gentoo]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Login to GHCR
run: echo "${{ secrets.GORELEASER_GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Download all XBPS artifacts
uses: actions/download-artifact@v4
with:
pattern: xbps-*
path: ${{ runner.temp }}/xbps-packages/
merge-multiple: true
- name: Download gentoo overlay
uses: actions/download-artifact@v4
with:
name: gentoo-overlay
path: ${{ runner.temp }}/gentoo-overlay/
- name: Extract version
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Run GoReleaser (publish)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
- name: Upload XBPS packages to release
env:
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
run: |
# Add XBPS checksums to checksums.txt
cd ${{ runner.temp }}/xbps-packages/
sha256sum *.xbps >> ${{ github.workspace }}/dist/checksums.txt
cd ${{ github.workspace }}
# Upload XBPS packages
gh release upload "${{ github.ref_name }}" ${{ runner.temp }}/xbps-packages/*.xbps --repo "${{ github.repository }}"
- name: Upload Gentoo ebuild to release
env:
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
EBUILD_FILE="${{ runner.temp }}/gentoo-overlay/app-misc/d4s/d4s-${VERSION}.ebuild"
# Add ebuild checksum
sha256sum "${EBUILD_FILE}" | sed "s|${{ runner.temp }}/gentoo-overlay/app-misc/d4s/||" >> dist/checksums.txt
# Upload ebuild
gh release upload "${{ github.ref_name }}" "${EBUILD_FILE}" --repo "${{ github.repository }}"
- name: Update checksums.txt with all artifacts
env:
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
run: |
gh release upload "${{ github.ref_name }}" dist/checksums.txt --clobber --repo "${{ github.repository }}"
- uses: actions/attest-build-provenance@v3
with:
subject-checksums: ./dist/checksums.txt
- uses: actions/attest-build-provenance@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
subject-checksums: ./dist/digests.txt
- name: Generate Gentoo Manifest and push overlay
env:
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
OVERLAY_DIR="${{ runner.temp }}/overlay"
if ! gh repo view jr-k/gentoo-d4s &>/dev/null; then
gh repo create jr-k/gentoo-d4s --public --description "Gentoo overlay for d4s"
sleep 2
fi
git clone "https://x-access-token:${GH_TOKEN}@github.com/jr-k/gentoo-d4s.git" "${OVERLAY_DIR}" || {
mkdir -p "${OVERLAY_DIR}"
cd "${OVERLAY_DIR}"
git init
git remote add origin "https://x-access-token:${GH_TOKEN}@github.com/jr-k/gentoo-d4s.git"
cd -
}
cp -r ${{ runner.temp }}/gentoo-overlay/* "${OVERLAY_DIR}/"
cd "${OVERLAY_DIR}/app-misc/d4s"
for arch in amd64 arm64 armv7 x86; do
TARBALL="d4s_${VERSION}_linux_${arch}.tar.gz"
URL="https://github.com/jr-k/d4s/releases/download/v${VERSION}/${TARBALL}"
curl -sL -o "/tmp/${TARBALL}" "${URL}"
SIZE=$(stat -c%s "/tmp/${TARBALL}")
SHA512=$(sha512sum "/tmp/${TARBALL}" | cut -d' ' -f1)
BLAKE2B=$(b2sum "/tmp/${TARBALL}" | cut -d' ' -f1)
echo "DIST ${TARBALL} ${SIZE} BLAKE2B ${BLAKE2B} SHA512 ${SHA512}" >> Manifest
done
cd "${OVERLAY_DIR}"
git config user.name "GoReleaser Bot"
git config user.email "bot@goreleaser.com"
git add -A
git commit -m "Update d4s to ${VERSION}" || exit 0
git push