Skip to content

Commit 0d19cf7

Browse files
committed
core(redo xbps and gentoo)
1 parent 52366b8 commit 0d19cf7

1 file changed

Lines changed: 221 additions & 1 deletion

File tree

.github/workflows/build.yaml

Lines changed: 221 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,151 @@ jobs:
5252
name: dist
5353
path: dist/
5454

55+
xbps:
56+
runs-on: ubuntu-latest
57+
needs: build
58+
container:
59+
image: ghcr.io/void-linux/void-glibc-full:latest
60+
strategy:
61+
fail-fast: true
62+
matrix:
63+
include:
64+
- arch: x86_64
65+
goreleaser_arch: amd64
66+
- arch: i686
67+
goreleaser_arch: 386
68+
- arch: aarch64
69+
goreleaser_arch: arm64
70+
- arch: armv6l
71+
goreleaser_arch: armv6
72+
- arch: armv7l
73+
goreleaser_arch: armv7
74+
steps:
75+
- name: Download dist artifacts
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: dist
79+
path: dist/
80+
81+
- name: Extract version
82+
id: version
83+
run: |
84+
VERSION=$(cat dist/metadata.json | grep -o '"version":"[^"]*"' | cut -d'"' -f4)
85+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
86+
87+
- name: Build XBPS package
88+
run: |
89+
xbps-install -Sy xbps
90+
91+
BINARY="dist/d4s_linux_${{ matrix.goreleaser_arch }}*/d4s"
92+
if [ "${{ matrix.goreleaser_arch }}" = "armv6" ]; then
93+
BINARY="dist/d4s_linux_arm_6/d4s"
94+
elif [ "${{ matrix.goreleaser_arch }}" = "armv7" ]; then
95+
BINARY="dist/d4s_linux_arm_7/d4s"
96+
fi
97+
98+
PKG_DIR="pkg_${{ matrix.arch }}"
99+
mkdir -p "${PKG_DIR}/usr/bin"
100+
mkdir -p "${PKG_DIR}/usr/share/doc/d4s"
101+
102+
cp ${BINARY} "${PKG_DIR}/usr/bin/d4s"
103+
chmod 755 "${PKG_DIR}/usr/bin/d4s"
104+
cp dist/d4s_linux_${{ matrix.goreleaser_arch }}*/LICENSE* "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || true
105+
cp dist/d4s_linux_${{ matrix.goreleaser_arch }}*/README* "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || true
106+
107+
cd "${PKG_DIR}"
108+
xbps-create -A ${{ matrix.arch }} \
109+
-n "d4s-${{ steps.version.outputs.version }}_1" \
110+
-s "Master Docker like a pro, right from your terminal" \
111+
-l "Apache-2.0" \
112+
-m "jr-k <jrk@jierka.com>" \
113+
-H "https://d4scli.io" \
114+
.
115+
mv *.xbps ../
116+
117+
- name: Upload XBPS artifact
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: xbps-${{ matrix.arch }}
121+
path: "*.xbps"
122+
123+
gentoo:
124+
runs-on: ubuntu-latest
125+
needs: build
126+
steps:
127+
- name: Download dist artifacts
128+
uses: actions/download-artifact@v4
129+
with:
130+
name: dist
131+
path: dist/
132+
133+
- name: Extract version
134+
id: version
135+
run: |
136+
VERSION=$(cat dist/metadata.json | grep -o '"version":"[^"]*"' | cut -d'"' -f4)
137+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
138+
139+
- name: Generate ebuild
140+
run: |
141+
VERSION="${{ steps.version.outputs.version }}"
142+
EBUILD_DIR="gentoo-overlay/app-misc/d4s"
143+
mkdir -p "${EBUILD_DIR}"
144+
145+
cat > "${EBUILD_DIR}/d4s-${VERSION}.ebuild" << 'EBUILD_EOF'
146+
# Copyright 2024 Gentoo Authors
147+
# Distributed under the terms of the Apache-2.0 license
148+
149+
EAPI=8
150+
151+
DESCRIPTION="Master Docker like a pro, right from your terminal"
152+
HOMEPAGE="https://d4scli.io https://github.com/jr-k/d4s"
153+
154+
BASE_URI="https://github.com/jr-k/d4s/releases/download/v${PV}"
155+
SRC_URI="
156+
amd64? ( ${BASE_URI}/d4s_${PV}_linux_amd64.tar.gz )
157+
arm64? ( ${BASE_URI}/d4s_${PV}_linux_arm64.tar.gz )
158+
arm? ( ${BASE_URI}/d4s_${PV}_linux_armv7.tar.gz )
159+
x86? ( ${BASE_URI}/d4s_${PV}_linux_x86.tar.gz )
160+
"
161+
162+
LICENSE="Apache-2.0"
163+
SLOT="0"
164+
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
165+
166+
RDEPEND=""
167+
DEPEND=""
168+
169+
S="${WORKDIR}"
170+
171+
QA_PREBUILT="usr/bin/d4s"
172+
173+
src_install() {
174+
dobin d4s
175+
dodoc README.md LICENSE
176+
}
177+
EBUILD_EOF
178+
179+
sed -i 's/^ //' "${EBUILD_DIR}/d4s-${VERSION}.ebuild"
180+
181+
mkdir -p gentoo-overlay/metadata
182+
cat > gentoo-overlay/metadata/layout.conf << 'EOF'
183+
masters = gentoo
184+
auto-sync = false
185+
EOF
186+
sed -i 's/^ //' gentoo-overlay/metadata/layout.conf
187+
188+
mkdir -p gentoo-overlay/profiles
189+
echo "gentoo-d4s" > gentoo-overlay/profiles/repo_name
190+
191+
- name: Upload gentoo overlay artifact
192+
uses: actions/upload-artifact@v4
193+
with:
194+
name: gentoo-overlay
195+
path: gentoo-overlay/
196+
55197
release:
56198
runs-on: ubuntu-latest
57-
needs: [build]
199+
needs: [build, xbps, gentoo]
58200
steps:
59201
- name: Checkout
60202
uses: actions/checkout@v4
@@ -77,6 +219,19 @@ jobs:
77219
with:
78220
go-version: stable
79221

222+
- name: Download all XBPS artifacts
223+
uses: actions/download-artifact@v4
224+
with:
225+
pattern: xbps-*
226+
path: ${{ runner.temp }}/xbps-packages/
227+
merge-multiple: true
228+
229+
- name: Download gentoo overlay
230+
uses: actions/download-artifact@v4
231+
with:
232+
name: gentoo-overlay
233+
path: ${{ runner.temp }}/gentoo-overlay/
234+
80235
- name: Extract version
81236
id: version
82237
run: |
@@ -92,6 +247,31 @@ jobs:
92247
env:
93248
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
94249

250+
- name: Upload XBPS packages to release
251+
env:
252+
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
253+
run: |
254+
# Add XBPS checksums to checksums.txt
255+
cd ${{ runner.temp }}/xbps-packages/
256+
sha256sum *.xbps >> ${{ github.workspace }}/dist/checksums.txt
257+
cd ${{ github.workspace }}
258+
259+
# Upload XBPS packages
260+
gh release upload "${{ github.ref_name }}" ${{ runner.temp }}/xbps-packages/*.xbps --repo "${{ github.repository }}"
261+
262+
- name: Upload Gentoo ebuild to release
263+
env:
264+
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
265+
run: |
266+
VERSION="${{ steps.version.outputs.version }}"
267+
EBUILD_FILE="${{ runner.temp }}/gentoo-overlay/app-misc/d4s/d4s-${VERSION}.ebuild"
268+
269+
# Add ebuild checksum
270+
sha256sum "${EBUILD_FILE}" | sed "s|${{ runner.temp }}/gentoo-overlay/app-misc/d4s/||" >> dist/checksums.txt
271+
272+
# Upload ebuild
273+
gh release upload "${{ github.ref_name }}" "${EBUILD_FILE}" --repo "${{ github.repository }}"
274+
95275
- name: Update checksums.txt with all artifacts
96276
env:
97277
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
@@ -106,3 +286,43 @@ jobs:
106286
if: startsWith(github.ref, 'refs/tags/v')
107287
with:
108288
subject-checksums: ./dist/digests.txt
289+
- name: Generate Gentoo Manifest and push overlay
290+
env:
291+
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
292+
run: |
293+
VERSION="${{ steps.version.outputs.version }}"
294+
OVERLAY_DIR="${{ runner.temp }}/overlay"
295+
296+
if ! gh repo view jr-k/gentoo-d4s &>/dev/null; then
297+
gh repo create jr-k/gentoo-d4s --public --description "Gentoo overlay for d4s"
298+
sleep 2
299+
fi
300+
301+
git clone "https://x-access-token:${GH_TOKEN}@github.com/jr-k/gentoo-d4s.git" "${OVERLAY_DIR}" || {
302+
mkdir -p "${OVERLAY_DIR}"
303+
cd "${OVERLAY_DIR}"
304+
git init
305+
git remote add origin "https://x-access-token:${GH_TOKEN}@github.com/jr-k/gentoo-d4s.git"
306+
cd -
307+
}
308+
309+
cp -r ${{ runner.temp }}/gentoo-overlay/* "${OVERLAY_DIR}/"
310+
311+
cd "${OVERLAY_DIR}/app-misc/d4s"
312+
for arch in amd64 arm64 armv7 x86; do
313+
TARBALL="d4s_${VERSION}_linux_${arch}.tar.gz"
314+
URL="https://github.com/jr-k/d4s/releases/download/v${VERSION}/${TARBALL}"
315+
curl -sL -o "/tmp/${TARBALL}" "${URL}"
316+
SIZE=$(stat -c%s "/tmp/${TARBALL}")
317+
SHA512=$(sha512sum "/tmp/${TARBALL}" | cut -d' ' -f1)
318+
BLAKE2B=$(b2sum "/tmp/${TARBALL}" | cut -d' ' -f1)
319+
echo "DIST ${TARBALL} ${SIZE} BLAKE2B ${BLAKE2B} SHA512 ${SHA512}" >> Manifest
320+
done
321+
cd "${OVERLAY_DIR}"
322+
323+
git config user.name "GoReleaser Bot"
324+
git config user.email "bot@goreleaser.com"
325+
git add -A
326+
git commit -m "Update d4s to ${VERSION}" || exit 0
327+
git push
328+

0 commit comments

Comments
 (0)