Skip to content

Commit 7f840a5

Browse files
committed
ci: add static musl binaries
Add build & test of static musl binaries to the publish workflow. fixes #330
1 parent e406d98 commit 7f840a5

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

.github/workflows/publish.yml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,64 @@ jobs:
2525
name: patchelf
2626
path: dist/*
2727

28-
publish:
29-
name: Publish tarballs
28+
build_binaries:
29+
name: Build static musl binaries
3030
needs: [build_tarballs]
31+
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
platform: ["amd64", "i386", "ppc64le", "arm64v8", "arm32v7", "s390x"]
36+
steps:
37+
- name: Set up QEMU
38+
if: matrix.platform != 'amd64'
39+
uses: docker/setup-qemu-action@v1
40+
41+
- uses: actions/download-artifact@v2
42+
with:
43+
name: patchelf
44+
path: dist
45+
- name: Build binaries
46+
env:
47+
CXXFLAGS: "-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wformat -Werror=format-security -O2 -static"
48+
run: |
49+
cat <<EOF > build.sh
50+
set -e
51+
set -x
52+
apk add build-base
53+
tar -xf dist/*.tar.bz2
54+
rm -f dist/*
55+
cd patchelf-*
56+
./configure --prefix /patchelf
57+
make check
58+
make install-strip
59+
cd -
60+
tar -czf ./dist/patchelf-\$(cat patchelf-*/version)-\$(uname -m).tar.gz -C /patchelf .
61+
EOF
62+
63+
if [ "${{ matrix.platform }}" == "i386" ]; then
64+
ENTRYPOINT=linux32
65+
else
66+
ENTRYPOINT=
67+
fi
68+
docker run -e CXXFLAGS -v $(pwd):/gha ${{ matrix.platform }}/alpine:3.15 ${ENTRYPOINT} sh -ec "cd /gha && sh ./build.sh"
69+
- name: Check binaries
70+
run: |
71+
cat <<EOF > check.sh
72+
set -e
73+
set -x
74+
tar -xf ./dist/patchelf-*-*.tar.gz
75+
./bin/patchelf --version
76+
EOF
77+
docker run -v $(pwd):/gha ${{ matrix.platform }}/debian:stable-slim sh -ec "cd /gha && sh ./check.sh"
78+
- uses: actions/upload-artifact@v2
79+
with:
80+
name: patchelf
81+
path: dist/*
82+
83+
publish:
84+
name: Publish tarballs & binaries
85+
needs: [build_tarballs, build_binaries]
3186
if: github.event_name == 'push' && github.repository == 'NixOS/patchelf' && startsWith(github.ref, 'refs/tags/')
3287
runs-on: ubuntu-latest
3388
steps:

0 commit comments

Comments
 (0)