add release and build scripts
This commit is contained in:
parent
b0e83bcecc
commit
4bbae178ca
36
.build.yml
36
.build.yml
@ -9,36 +9,12 @@ environment:
|
|||||||
tasks:
|
tasks:
|
||||||
- setup: |
|
- setup: |
|
||||||
sudo apt-get purge gcc -y && sudo apt-get autoremove -y
|
sudo apt-get purge gcc -y && sudo apt-get autoremove -y
|
||||||
|
- lint:
|
||||||
|
cd bazel-zig-cc
|
||||||
|
shellcheck $(awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(git ls-files)))
|
||||||
- test_list_toolchains: |
|
- test_list_toolchains: |
|
||||||
cd bazel-zig-cc; . .envrc; echo "Available toolchains:"
|
cd bazel-zig-cc; . .envrc; echo "Available toolchains:"
|
||||||
bazel query @zig_sdk//... | sed -En '/.*_toolchain$/ s/.*:(.*)_toolchain$/\1/p'
|
bazel query @zig_sdk//... | sed -En '/.*_toolchain$/ s/.*:(.*)_toolchain$/\1/p'
|
||||||
- test_default: |
|
- test_hello_on_toolchains: |
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
cd bazel-zig-cc
|
||||||
//test:hello | \
|
./ci/test
|
||||||
grep -q "ELF 64-bit.* x86-64.* dynamically linked"
|
|
||||||
- test_amd64-linux-gnu: |
|
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
|
||||||
--platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo //test:hello | \
|
|
||||||
grep -q "ELF 64-bit.* x86-64.* dynamically linked"
|
|
||||||
- test_amd64-linux-musl: |
|
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
|
||||||
--platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
|
|
||||||
--extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain //test:hello | \
|
|
||||||
grep -q "ELF 64-bit.* x86-64.* statically linked"
|
|
||||||
- test_arm64-linux-gnu: |
|
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
|
||||||
--platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo //test:hello | \
|
|
||||||
grep -q "ELF 64-bit.* ARM aarch64.* dynamically linked"
|
|
||||||
- test_arm64-linux-musl: |
|
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
|
||||||
--platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo \
|
|
||||||
--extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain //test:hello | \
|
|
||||||
grep -q "ELF 64-bit.* ARM aarch64.* statically linked"
|
|
||||||
- test_amd64-macos: |
|
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
|
||||||
--platforms @io_bazel_rules_go//go/toolchain:darwin_amd64_cgo //test:hello | \
|
|
||||||
grep -q "Mach-O 64-bit x86_64 executable"
|
|
||||||
- test_arm64-macos-gnu: |
|
|
||||||
cd bazel-zig-cc; . .envrc; ./build-and-file \
|
|
||||||
--platforms @io_bazel_rules_go//go/toolchain:darwin_arm64_cgo //test:hello | \
|
|
||||||
grep -q "Mach-O 64-bit arm64 executable"
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# 'bazel' binary is stored in $HOME in builds.sr.ht.
|
|
||||||
|
|
||||||
# -o pipefail fails `bazel aquery ...`: it errs if it can't output to stdout.
|
|
||||||
set -xeu
|
|
||||||
|
|
||||||
bazel build "$@"
|
|
||||||
execpath=$(bazel aquery "$@" 2>/dev/null | \
|
|
||||||
awk "/action 'GoLink/{f=1};/Outputs: / &&f{print;exit}" | \
|
|
||||||
awk -F'\\[|\\]' '{print $2}')
|
|
||||||
|
|
||||||
file "$execpath" | tee /dev/stderr
|
|
58
ci/test
Executable file
58
ci/test
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
. .envrc
|
||||||
|
|
||||||
|
_build_and_file() {
|
||||||
|
bazel build --color=yes --curses=yes "$@"
|
||||||
|
local execpath=$(bazel aquery "$@" 2>/dev/null | \
|
||||||
|
awk "/action 'GoLink/{f=1};/Outputs: /&&f{print;exit}" | \
|
||||||
|
awk -F'\\[|\\]' '{print $2}')
|
||||||
|
file "$execpath" | tee /dev/stderr
|
||||||
|
}
|
||||||
|
|
||||||
|
_test() {
|
||||||
|
local name=$1
|
||||||
|
local glob=$2
|
||||||
|
shift; shift;
|
||||||
|
>&2 echo "================================================================"
|
||||||
|
>&2 echo "Testing $name and looking for '$glob':"
|
||||||
|
>&2 echo " bazel build $* //test:hello"
|
||||||
|
>&2 echo
|
||||||
|
if _build_and_file "$@" //test:hello | grep -q "$glob"; then
|
||||||
|
>&2 echo "OK $name"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
>&2 echo "FAIL $name: glob does not match"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_test "Host" \
|
||||||
|
"ELF 64-bit.* x86-64.* dynamically linked"
|
||||||
|
|
||||||
|
_test "linux_amd64_gnu" \
|
||||||
|
"ELF 64-bit.* x86-64.* dynamically linked" \
|
||||||
|
--platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo
|
||||||
|
|
||||||
|
_test "linux_amd64_musl" \
|
||||||
|
"ELF 64-bit.* x86-64.* statically linked" \
|
||||||
|
--platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
|
||||||
|
--extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain
|
||||||
|
|
||||||
|
_test "linux_arm64_gnu" \
|
||||||
|
"ELF 64-bit.* ARM aarch64.* dynamically linked" \
|
||||||
|
--platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo
|
||||||
|
|
||||||
|
_test "linux_arm64_musl" \
|
||||||
|
"ELF 64-bit.* ARM aarch64.* statically linked" \
|
||||||
|
--platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo \
|
||||||
|
--extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain
|
||||||
|
|
||||||
|
_test "darwin_amd64" \
|
||||||
|
"Mach-O 64-bit x86_64 executable" \
|
||||||
|
--platforms @io_bazel_rules_go//go/toolchain:darwin_amd64_cgo
|
||||||
|
|
||||||
|
_test "darwin_arm64" \
|
||||||
|
"Mach-O 64-bit arm64 executable" \
|
||||||
|
--platforms @io_bazel_rules_go//go/toolchain:darwin_arm64_cgo
|
22
release
Executable file
22
release
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
_err(){ >&2 echo "ERROR: $*"; exit 1; }
|
||||||
|
|
||||||
|
git status --porcelain | grep -q "" &&
|
||||||
|
_err "working tree is dirty, commit your changes first."
|
||||||
|
|
||||||
|
[[ "$1" =~ ^v([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]] || \
|
||||||
|
_err "arg1 accepts the following formats: v1.0 v1.0.0"
|
||||||
|
|
||||||
|
git tag | grep -q "^$1$" &&
|
||||||
|
_err "tag $1 already exists"
|
||||||
|
|
||||||
|
last_tag=$(git tag | tail -1)
|
||||||
|
|
||||||
|
{
|
||||||
|
echo bazel-zig-cc "$1"
|
||||||
|
echo
|
||||||
|
echo Changelog since "$last_tag":
|
||||||
|
git log --pretty=format:"- [%cn] %s" "$last_tag"..HEAD
|
||||||
|
} | git tag -u motiejus@jakstys.lt -F - "$1"
|
Loading…
Reference in New Issue
Block a user