Repository navigation
104 lines (94 loc) · 3.81 KB
/
Copy pathstatic-linux-binary.yaml
File metadata and controls
104 lines (94 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
## Build a static x86_64 Linux binary (musl, built on Alpine) and attach it to GitHub releases.
## See .github/scripts/build-static-linux.sh for how it is built and why.
name: static-linux-binary
on:
release:
types: [published]
workflow_dispatch:
pull_request:
# Besides its own files, changes that can break a static build, so that this
# is found in a pull request rather than when making a release.
paths:
- .github/workflows/static-linux-binary.yaml
- .github/scripts/build-static-linux.sh
- CMakeLists.txt
- "**/CMakeLists.txt"
- Cargo.toml
- Cargo.lock
permissions:
contents: read
jobs:
build:
name: Static x86_64 Linux binary
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: write # to attach the tarball to the release
env:
DIST: build-static-linux/dist
steps:
- name: Check out this repository
uses: actions/checkout@v7
with:
submodules: recursive
- name: Build in Alpine
run: |
docker run --rm \
-v "$PWD":/src -w /src \
-e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" \
rust:alpine sh .github/scripts/build-static-linux.sh
# Run it on the (glibc) runner, which is not where it was built, and from a
# prefix other than the one it was built for (/usr/local), as a user
# unpacking it under $HOME/.local would.
- name: Smoke test
run: |
set -eu
cd "$DIST"
archive=$(ls task-*-linux-x86_64-static.tar.gz)
sha256sum -c "$archive.sha256"
prefix="$RUNNER_TEMP/prefix"
mkdir "$prefix"
tar -C "$prefix" --strip-components=1 -xzf "$archive"
task="$prefix/bin/task"
file "$task" | tee /dev/stderr | grep -Eq 'statically linked|static-pie linked'
for f in \
share/man/man1/task.1 \
share/man/man5/taskrc.5 \
share/doc/task/rc/default.theme \
share/doc/task/rc/dark-256.theme \
share/doc/task/rc/holidays.en-US.rc \
share/bash-completion/completions/task \
share/zsh/site-functions/_task; do
test -f "$prefix/$f" || { echo "missing from the tarball: $f" >&2; exit 1; }
done
# default.theme is included by the built-in defaults; the other two by this rc file.
export TASKRC="$RUNNER_TEMP/taskrc" TASKDATA="$RUNNER_TEMP/taskdata"
mkdir "$TASKDATA"
printf 'data.location=%s\ninclude dark-256.theme\ninclude holidays.en-US.rc\n' "$TASKDATA" > "$TASKRC"
"$task" rc.confirmation=no add smoke test
"$task" export | grep -q 'smoke test'
# Releases get it as an asset; anything else keeps it for a few days, so
# that a pull request's tarball can be downloaded and tried.
- name: Keep the tarball
if: github.event_name != 'release'
uses: actions/upload-artifact@v7
with:
name: static-linux-binary
path: ${{ env.DIST }}
retention-days: 7
- name: Attach to release
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.event.release.tag_name }}
run: |
set -eu
cd "$DIST"
version=$(ls task-*-linux-x86_64-static.tar.gz | sed -E 's/^task-(.*)-linux-x86_64-static\.tar\.gz$/\1/')
# Never attach a binary built as one version to the release of another.
case "$TAG" in
"v$version" | "v$version"-*) ;;
*) echo "::error::release $TAG does not match the built version $version"; exit 1 ;;
esac
gh release upload "$TAG" task-*-linux-x86_64-static.tar.gz task-*-linux-x86_64-static.tar.gz.sha256 --clobber