Skip to content

Commit 89c016e

Browse files
authored
Merge pull request #43 from ncopa/release-workflow
Build only multiarch binaries on tags
2 parents 122f0ac + cc22d11 commit 89c016e

File tree

2 files changed

+124
-54
lines changed

2 files changed

+124
-54
lines changed

.github/workflows/build.yaml

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: Build su-exec
22

33
on:
44
push:
5-
branches: ["**"]
6-
tags:
7-
- "v*"
85
pull_request:
96

107
jobs:
@@ -28,60 +25,25 @@ jobs:
2825
ls -l su-exec
2926
file su-exec
3027
31-
build-static:
28+
build-alpine:
29+
name: Alpine build
3230
runs-on: ubuntu-latest
33-
strategy:
34-
fail-fast: false
35-
matrix:
36-
include:
37-
- platform: linux/amd64
38-
arch: amd64
39-
- platform: linux/arm64
40-
arch: arm64
41-
- platform: linux/ppc64le
42-
arch: ppc64le
43-
- platform: linux/riscv64
44-
arch: riscv64
45-
- platform: linux/s390x
46-
arch: s390x
47-
- platform: linux/arm/v7
48-
arch: armv7
49-
- platform: linux/386
50-
arch: x86
51-
31+
container:
32+
image: alpine:3.22
5233
steps:
34+
- name: Install tools needed for checkout
35+
run: |
36+
apk add --no-cache git ca-certificates build-base
37+
5338
- name: Checkout
5439
uses: actions/checkout@v4
55-
56-
- name: Enable QEMU
57-
uses: docker/setup-qemu-action@v3
58-
with:
59-
platforms: all
60-
61-
- name: Build static inside Alpine (${{ matrix.arch }})
62-
shell: bash
40+
41+
- name: Build
42+
run: make su-exec su-exec-static && strip su-exec su-exec-static
43+
44+
- name: Show binary info
6345
run: |
64-
set -euxo pipefail
65-
66-
docker run --rm \
67-
--platform=${{ matrix.platform }} \
68-
-e HOST_UID="$(id -u)" \
69-
-e HOST_GID="$(id -g)" \
70-
-v "$PWD":/src -w /src \
71-
alpine:3.22 \
72-
sh -exc '
73-
apk add --no-cache build-base file
74-
make clean
75-
make su-exec
76-
./su-exec "$HOST_UID:$HOST_GID" make su-exec-static
77-
./su-exec "$HOST_UID:$HOST_GID" strip su-exec-static
78-
file su-exec-static
79-
'
80-
81-
mv su-exec-static su-exec-static-${{ matrix.arch }}
46+
ls -l su-exec su-exec-static
47+
file su-exec su-exec-static
48+
ldd su-exec su-exec-static
8249
83-
- name: Upload artifact (${{ matrix.arch }})
84-
uses: actions/upload-artifact@v4
85-
with:
86-
name: su-exec-static-${{ matrix.arch }}
87-
path: su-exec-static-${{ matrix.arch }}

.github/workflows/release.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
ALPINE_IMAGE: alpine:3.22
10+
11+
jobs:
12+
build-static:
13+
name: build (${{ matrix.arch }})
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- platform: linux/amd64
20+
arch: x86_64
21+
- platform: linux/arm64
22+
arch: arm64
23+
- platform: linux/ppc64le
24+
arch: ppc64le
25+
- platform: linux/riscv64
26+
arch: riscv64
27+
- platform: linux/s390x
28+
arch: s390x
29+
- platform: linux/arm/v7
30+
arch: armv7
31+
- platform: linux/386
32+
arch: x86
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Tag name
39+
id: tag-name
40+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
41+
42+
- name: Enable QEMU
43+
uses: docker/setup-qemu-action@v3
44+
with:
45+
platforms: all
46+
47+
- name: Build static (${{ matrix.arch }})
48+
shell: bash
49+
run: |
50+
set -euxo pipefail
51+
52+
docker run --rm \
53+
--platform=${{ matrix.platform }} \
54+
-e HOST_UID="$(id -u)" \
55+
-e HOST_GID="$(id -g)" \
56+
-v "$PWD":/src -w /src \
57+
"${ALPINE_IMAGE}" \
58+
sh -exc '
59+
apk add --no-cache build-base file
60+
make clean
61+
make su-exec
62+
./su-exec "$HOST_UID:$HOST_GID" make su-exec-static
63+
./su-exec "$HOST_UID:$HOST_GID" strip su-exec-static
64+
file su-exec-static
65+
'
66+
67+
mv su-exec-static "su-exec-static-${{ steps.tag-name.outputs.tag }}-${{ matrix.arch }}"
68+
69+
- name: Upload artifact (${{ matrix.arch }})
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: su-exec-static-${{ steps.tag-name.outputs.tag }}-${{ matrix.arch }}
73+
path: su-exec-static-${{ steps.tag-name.outputs.tag }}-${{ matrix.arch }}
74+
75+
release:
76+
name: create release
77+
runs-on: ubuntu-latest
78+
needs: build-static
79+
80+
steps:
81+
- name: Tag name
82+
id: tag-name
83+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
84+
85+
- name: Download all artifacts
86+
uses: actions/download-artifact@v4
87+
with:
88+
path: dist
89+
merge-multiple: true
90+
91+
- name: Generate SHA256SUMS
92+
run: |
93+
cd dist
94+
sha256sum su-exec-* > SHA256SUMS
95+
cat SHA256SUMS
96+
97+
- name: Create release and upload binaries
98+
uses: softprops/action-gh-release@v2
99+
with:
100+
tag_name: ${{ steps.tag-name.outputs.tag }}
101+
name: ${{ steps.tag-name.outputs.tag }}
102+
draft: true
103+
prerelease: ${{ contains(steps.tag-name.outputs.tag, '-') }}
104+
files: |
105+
dist/su-exec-*
106+
dist/SHA256SUMS
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)