amend workflow to build static binary and create release #6
This file contains 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: C Program Build | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Build static binary in alpine container | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: alpine:latest | |
options: --rm -v ${{ github.workspace }}:/work --workdir /work | |
run: | | |
apk add --no-cache build-base | |
CFLAGS=-static LDFLAGS=-static make all | |
- name: verify binary is statically linked | |
run: ldd sherlock || echo "Binary is statically linked" | |
- name: add tarfile | |
run: | | |
fakeroot tar cf sherlock.tgz --gzip sherlock | |
- name: Upload compiled sherlock | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sherlock | |
path: sherlock | |
- name: Release (if tagged) | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
sherlock.tgz | |
draft: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |