|
| 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