Skip to content

Commit 0ae2707

Browse files
authored
Merge pull request #349 from mayeut/musl-static-build
Add build & test of static musl binaries to the publish workflow
2 parents 2ac5798 + 7f840a5 commit 0ae2707

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

.github/workflows/publish.yml

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: Publish
22
on:
3+
pull_request:
34
push:
5+
branches:
6+
- '*'
47
tags:
58
- '*'
69

710
jobs:
8-
build:
9-
name: Publish tarballs
11+
build_tarballs:
12+
name: Build tarballs
1013
runs-on: ubuntu-latest
1114
steps:
1215
- name: Checkout
@@ -17,6 +20,76 @@ jobs:
1720
nix-build -A hydraJobs.tarball
1821
install -D ./result/tarballs/*.tar.bz2 ./dist/patchelf-$(cat version).tar.bz2
1922
install -D ./result/tarballs/*.tar.gz ./dist/patchelf-$(cat version).tar.gz
23+
- uses: actions/upload-artifact@v2
24+
with:
25+
name: patchelf
26+
path: dist/*
27+
28+
build_binaries:
29+
name: Build static musl binaries
30+
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]
86+
if: github.event_name == 'push' && github.repository == 'NixOS/patchelf' && startsWith(github.ref, 'refs/tags/')
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/download-artifact@v2
90+
with:
91+
name: patchelf
92+
path: dist
2093
- name: Upload binaries to release
2194
uses: svenstaro/upload-release-action@v2
2295
with:

0 commit comments

Comments
 (0)