Build a static binary to be used on other distros #22
Workflow file for this run
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: Go | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
main: | |
name: Main | |
runs-on: ubuntu-22.04 | |
permissions: | |
pull-requests: write | |
contents: read | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
- name: Verify Docker | |
id: verify_docker | |
run: | | |
docker run --rm hello-world:latest > /dev/null | |
docker rmi hello-world:latest > /dev/null | |
docker version | |
docker compose version | |
- name: Cache docker images | |
uses: ScribeMD/docker-cache@0.3.3 | |
with: | |
key: | | |
docker-${{ runner.os }}-${{ hashFiles( | |
'docker-compose*.yml', | |
'docker/**' | |
) }} | |
- name: Fix goup membership | |
id: fix_group | |
run: | | |
# Add the existing `runner` group to avoid the `docker` one | |
sudo adduser runner runner | |
echo "_GID=$(grep -E "^runner:" /etc/group | cut -d: -f3)" >> $GITHUB_ENV | |
- name: Build images | |
id: build_images | |
run: | | |
docker compose build --progress=plain \ | |
--build-arg uid=$(id -u) \ | |
--build-arg gid=${_GID} | |
- name: Go make | |
id: go_make | |
run: | | |
docker compose run go-shell sh -c "make mockdeps && make" | |
- name: Test binary | |
id: test_binary | |
run: | | |
# Run some basic test on the binary built earlier | |
echo -n "Test for a static executable: " | |
ldd ../trac2gitea | grep -q 'not a dynamic executable' \ | |
&& echo PASS \ | |
|| { echo FAIL; exit 1; } | |
echo -n "Test for usage prompt on execution: " | |
./trac2gitea --help 2>&1 | grep -q '^Usage' \ | |
&& echo 'PASS' \ | |
|| { echo 'FAIL'; exit 1; } |