Build and Release PELF tooling as a single-file executable #195
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release PELF tooling as a single-file executable | |
| concurrency: | |
| group: build-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| workflow_dispatch: | |
| #schedule: | |
| # - cron: "0 14 * * 0" | |
| jobs: | |
| build: | |
| name: "${{ matrix.name }} (${{ matrix.arch }})" | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| matrix: | |
| include: | |
| - runs-on: ubuntu-latest | |
| name: "cbuild.sh (amd64)" | |
| arch: x86_64 | |
| - runs-on: ubuntu-24.04-arm | |
| name: "cbuild.sh (arm64)" | |
| arch: aarch64 | |
| container: | |
| image: "alpine:edge" | |
| volumes: | |
| - /:/host # Jailbreak! | |
| - /tmp/node20:/__e/node20 | |
| steps: | |
| - name: Patch native Alpine NodeJS into Runner environment | |
| if: matrix.arch == 'aarch64' | |
| run: | | |
| apk add nodejs gcompat openssl | |
| sed -i "s:ID=alpine:ID=NotpineForGHA:" /etc/os-release | |
| # --- old workaround --- | |
| #ls /host/home/runner/*/* | |
| #cd /host/home/runner/runners/*/externals/ | |
| #rm -rf node20/* | |
| #mkdir node20/bin | |
| #ln -sfT /usr/bin/node node20/bin/node | |
| # --- second workaround --- | |
| mkdir -p /__e/node20/bin | |
| ln -sfT /usr/bin/node /__e/node20/bin/node | |
| ln -sfT /usr/bin/npm /__e/node20/bin/npm | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up GOBIN and install lib4bin | |
| run: | | |
| set -x | |
| apk add zstd git bash file binutils patchelf findutils grep sed strace go fuse3 fuse curl yq-go b3sum | |
| export GOBIN="$GITHUB_WORKSPACE/.local/bin" CGO_ENABLED=0 GO_LDFLAGS='-buildmode=static-pie' GOFLAGS='-ldflags=-static-pie -ldflags=-s -ldflags=-w' | |
| export DBIN_INSTALL_DIR="$GOBIN" DBIN_NOCONFIG=1 PATH="$GOBIN:$PATH" | |
| mkdir -p "$GOBIN" | |
| wget -qO- "https://raw.githubusercontent.com/xplshn/dbin/master/stubdl" | sh -s -- --install "$DBIN_INSTALL_DIR/dbin" -v | |
| "$DBIN_INSTALL_DIR/dbin" --silent add yq upx | |
| echo "PATH=$PATH" >> $GITHUB_ENV | |
| echo "DBIN_INSTALL_DIR=$GOBIN" >> $GITHUB_ENV | |
| echo "WITH_SHARUN=1" >> $GITHUB_ENV | |
| echo "GEN_LIB_PATH=1" >> $GITHUB_ENV | |
| echo "ANY_EXECUTABLE=1" >> $GITHUB_ENV | |
| mkdir "$GITHUB_WORKSPACE/dist" | |
| ROOTFS_URL="$(curl -qsL https://dl-cdn.alpinelinux.org/alpine/edge/releases/${{ matrix.arch }}/latest-releases.yaml | yq '.[0].file')" | |
| echo "https://dl-cdn.alpinelinux.org/alpine/edge/releases/${{ matrix.arch }}/${ROOTFS_URL}" >"$GITHUB_WORKSPACE/dist/alpineLinuxEdge.${{ matrix.arch }}.rootfsURL" | |
| ROOTFS_URL="https://dl-cdn.alpinelinux.org/alpine/edge/releases/${{ matrix.arch }}/${ROOTFS_URL}" | |
| export ROOTFS_URL | |
| echo "ROOTFS_URL=$ROOTFS_URL" >> "$GITHUB_ENV" | |
| apk add coreutils | |
| - name: Build AppBundle tooling | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| export CGO_ENABLED=0 GOFLAGS="-ldflags=-static-pie -ldflags=-s -ldflags=-w" GO_LDFLAGS="-buildmode=static-pie -s -w" | |
| export _RELEASE="1" | |
| ./cbuild.sh && ./cbuild.sh pelfCreator_extensions | |
| B3SUM_CHECKSUM="$(b3sum ./pelf | awk '{print $1}')" | |
| mv ./pelf "$GITHUB_WORKSPACE/dist/pelf_${{ matrix.arch }}" | |
| mv ./cmd/pelfCreator/pelfCreator "$GITHUB_WORKSPACE/dist/pelfCreator_${{ matrix.arch }}" | |
| mv ./cmd/pelfCreator/pelfCreatorExtension_archLinux.tar.zst "$GITHUB_WORKSPACE/dist/pelfCreatorExtension_archLinux_${{ matrix.arch }}".tar.zst | |
| mv ./cmd/misc/appstream-helper/appstream-helper "$GITHUB_WORKSPACE/dist/appstream-helper_${{ matrix.arch }}" | |
| echo "RELEASE_TAG=$(date +%d%m%Y)-$B3SUM_CHECKSUM" >> $GITHUB_ENV | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4.6.1 | |
| with: | |
| name: AppBundle-${{ matrix.arch }} | |
| path: ${{ github.workspace }}/dist/* | |
| - name: Set build output | |
| id: build_output | |
| run: | | |
| echo "release_tag=$(date +%d%m%Y)-$(b3sum ./pelf | awk '{print $1}')" >> $GITHUB_OUTPUT | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: List files | |
| run: find artifacts -type f | sort | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2.2.1 | |
| with: | |
| name: "Build ${{ needs.build.outputs.release_tag || github.run_number }}" | |
| tag_name: "${{ needs.build.outputs.release_tag || github.run_number }}" | |
| prerelease: false | |
| draft: false | |
| generate_release_notes: false | |
| make_latest: true | |
| files: | | |
| artifacts/* |