ci: restructure the Gitea pipeline into staged jobs
VoidBuildSystem CI / 1 · Requirements (push) Successful in 2s
VoidBuildSystem CI / 2 · Build (debug) (push) Successful in 2m58s
VoidBuildSystem CI / 2 · Build (asan) (push) Successful in 3m24s
VoidBuildSystem CI / 2 · Build (ubsan) (push) Successful in 3m58s
VoidBuildSystem CI / 2 · Build (relwithdebinfo) (push) Successful in 4m6s
VoidBuildSystem CI / 3 · Test (ubsan) (push) Successful in 2m24s
VoidBuildSystem CI / 3 · Test (asan) (push) Successful in 2m25s
VoidBuildSystem CI / 3 · Test (relwithdebinfo) (push) Failing after 7m13s
VoidBuildSystem CI / 3 · Test (debug) (push) Failing after 7m29s
VoidBuildSystem CI / 4 · Package (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped
VoidBuildSystem CI / 1 · Requirements (push) Successful in 2s
VoidBuildSystem CI / 2 · Build (debug) (push) Successful in 2m58s
VoidBuildSystem CI / 2 · Build (asan) (push) Successful in 3m24s
VoidBuildSystem CI / 2 · Build (ubsan) (push) Successful in 3m58s
VoidBuildSystem CI / 2 · Build (relwithdebinfo) (push) Successful in 4m6s
VoidBuildSystem CI / 3 · Test (ubsan) (push) Successful in 2m24s
VoidBuildSystem CI / 3 · Test (asan) (push) Successful in 2m25s
VoidBuildSystem CI / 3 · Test (relwithdebinfo) (push) Failing after 7m13s
VoidBuildSystem CI / 3 · Test (debug) (push) Failing after 7m29s
VoidBuildSystem CI / 4 · Package (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped
Split CI into requirements -> build matrix (Debug, RelWithDebInfo, ASan, UBSan) -> per-configuration tests -> packaging -> optional release, passing build outputs between stages as artifacts. The release stage now packages the RelWithDebInfo build and the queue stays skipped outside v* tags or a manual publish dispatch. Drop the libFuzzer job (the local fuzz harness stays in the tree) and fold release.yml into the pipeline's final stage.
This commit is contained in:
1 parent
92c4be9273
commit
d95fb0d2f8
2 files changed
+236
-209
No files matched your search
+236
-93
@@ -1,19 +1,41 @@
|
|||||||
# VoidBuildSystem CI (Gitea Actions).
|
# VoidBuildSystem CI (Gitea Actions).
|
||||||
#
|
#
|
||||||
# Runner: `echoion-release-serial` - the GCC 16.1.0 builder container (Debian-based,
|
# Multi-stage pipeline with one job per stage step:
|
||||||
# with CMake, Ninja, Node and pkg-config). GCC 16 is required for C++26; the generic
|
#
|
||||||
# `ubuntu-*` images ship an older GCC and are not used.
|
# 1. requirements verify the GCC 16 toolchain and install development headers
|
||||||
# Clang (for libFuzzer) and OpenSSL headers are installed at job time with apt.
|
# 2. build one job per configuration (Debug, RelWithDebInfo, ASan, UBSan)
|
||||||
|
# 3. test one job per build configuration, consuming its build artifact
|
||||||
|
# 4. package bundle the RelWithDebInfo binaries, the SDK and the source archive
|
||||||
|
# 5. release optional: publish the packages as a Gitea release (v* tag or
|
||||||
|
# a manual dispatch with publish=true)
|
||||||
|
#
|
||||||
|
# Runner: `echoion-release-serial` - the GCC 16 builder container (Debian-based,
|
||||||
|
# with CMake, Ninja, Node and pkg-config). GCC 16 is required for C++26.
|
||||||
|
#
|
||||||
|
# Jobs are isolated, so build outputs travel between stages as artifacts. The
|
||||||
|
# artifact paths are uploaded relative to the build directory and restored under
|
||||||
|
# the same workspace-relative location, keeping the absolute paths recorded in
|
||||||
|
# the CTest files valid.
|
||||||
name: VoidBuildSystem CI
|
name: VoidBuildSystem CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
tags: ["v*"]
|
||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
publish:
|
||||||
|
description: "Create/publish the Gitea release (only for a v* tag ref)"
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test-gcc16:
|
requirements:
|
||||||
|
name: "1 · Requirements"
|
||||||
runs-on: echoion-release-serial
|
runs-on: echoion-release-serial
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -25,112 +47,233 @@ jobs:
|
|||||||
echo "GCC 16 or newer is required for C++26 (found ${major:-unknown})" >&2
|
echo "GCC 16 or newer is required for C++26 (found ${major:-unknown})" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo 'int main() { return 0; }' | g++ -std=c++26 -freflection -fsyntax-only -x c++ -
|
||||||
cmake --version | head -1
|
cmake --version | head -1
|
||||||
ninja --version
|
cmake_major="$(cmake --version | sed -nE 's/^cmake version ([0-9]+).*/\1/p')"
|
||||||
- name: Configure (Debug, Ninja, GCC 16 C++26)
|
if [ "${cmake_major:-0}" -lt 4 ]; then
|
||||||
run: |
|
echo "CMake 4 or newer is required (found ${cmake_major:-unknown})" >&2
|
||||||
cmake -S . -B build/ci-gcc -G Ninja \
|
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
|
||||||
-DCMAKE_CXX_COMPILER=g++ \
|
|
||||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build/ci-gcc --parallel 4
|
|
||||||
- name: Run CTest suites
|
|
||||||
run: |
|
|
||||||
set -o pipefail
|
|
||||||
ctest --test-dir build/ci-gcc --output-on-failure 2>&1 | tee ctest.log
|
|
||||||
- name: Benchmark smoke run
|
|
||||||
run: build/ci-gcc/bin/vbs_benchmarks 15
|
|
||||||
- name: Upload build artifacts
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: vbs-debug-linux-x86_64
|
|
||||||
path: |
|
|
||||||
build/ci-gcc/bin/vbs
|
|
||||||
build/ci-gcc/bin/vbs-registry
|
|
||||||
build/ci-gcc/bin/vbs_v1_tests
|
|
||||||
build/ci-gcc/compile_commands.json
|
|
||||||
ctest.log
|
|
||||||
retention-days: 14
|
|
||||||
|
|
||||||
signing-openssl-gcc16:
|
|
||||||
runs-on: echoion-release-serial
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Install OpenSSL headers
|
|
||||||
run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y libssl-dev || sudo apt-get install -y libssl-dev
|
|
||||||
- name: Configure (Debug, Ninja, GCC 16 C++26, OpenSSL)
|
|
||||||
run: |
|
|
||||||
cmake -S . -B build/ci-openssl -G Ninja \
|
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
|
||||||
-DCMAKE_CXX_COMPILER=g++ \
|
|
||||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
||||||
- name: Build vbs_v1_tests
|
|
||||||
run: cmake --build build/ci-openssl --target vbs_v1_tests --parallel 4
|
|
||||||
- name: Run Signing suite with the OpenSSL backend
|
|
||||||
run: |
|
|
||||||
output=$(build/ci-openssl/bin/vbs_v1_tests --suite Signing --no-color)
|
|
||||||
printf '%s\n' "$output"
|
|
||||||
if printf '%s\n' "$output" | grep -q 'SKIP'; then
|
|
||||||
echo "Signing checks were skipped: the OpenSSL backend was not enabled" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
ninja --version
|
||||||
|
git --version
|
||||||
|
- name: Install the development requirements
|
||||||
|
run: |
|
||||||
|
# The optional backends (OpenSSL, SQLite3) are opportunistic: a runner that
|
||||||
|
# provides the GCC 16 toolchain already satisfies the mandatory requirements.
|
||||||
|
if ! command -v apt-get >/dev/null 2>&1; then
|
||||||
|
echo "apt-get is not available; using the toolchain provided by the runner"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sudo=""
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then sudo="sudo"; fi
|
||||||
|
missing=""
|
||||||
|
for package in libssl-dev libsqlite3-dev pkg-config; do
|
||||||
|
if command -v dpkg >/dev/null 2>&1 && dpkg -s "${package}" >/dev/null 2>&1; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
missing="${missing} ${package}"
|
||||||
|
done
|
||||||
|
if [ -n "${missing}" ]; then
|
||||||
|
${sudo} apt-get update
|
||||||
|
${sudo} apt-get install -y ${missing}
|
||||||
|
else
|
||||||
|
echo "all development packages are already installed"
|
||||||
|
fi
|
||||||
|
|
||||||
sanitizers-gcc16:
|
build:
|
||||||
|
name: "2 · Build (${{ matrix.name }})"
|
||||||
|
needs: requirements
|
||||||
runs-on: echoion-release-serial
|
runs-on: echoion-release-serial
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: debug
|
||||||
|
build_type: Debug
|
||||||
|
cxx_flags: ""
|
||||||
|
linker_flags: ""
|
||||||
|
- name: relwithdebinfo
|
||||||
|
build_type: RelWithDebInfo
|
||||||
|
cxx_flags: ""
|
||||||
|
linker_flags: ""
|
||||||
|
- name: asan
|
||||||
|
build_type: Debug
|
||||||
|
cxx_flags: "-fsanitize=address -fno-omit-frame-pointer"
|
||||||
|
linker_flags: "-fsanitize=address"
|
||||||
|
- name: ubsan
|
||||||
|
build_type: Debug
|
||||||
|
cxx_flags: "-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
|
||||||
|
linker_flags: "-fsanitize=undefined"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Configure with ASan + UBSan
|
- name: Configure (${{ matrix.name }}, ${{ matrix.build_type }})
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B build/ci-asan -G Ninja \
|
cmake -S . -B "build/${{ matrix.name }}" -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||||
-DCMAKE_CXX_COMPILER=g++ \
|
-DCMAKE_CXX_COMPILER=g++ \
|
||||||
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" \
|
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \
|
||||||
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" \
|
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.linker_flags }}" \
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
- name: Build
|
- name: Build (${{ matrix.name }})
|
||||||
run: cmake --build build/ci-asan --parallel 4
|
run: cmake --build "build/${{ matrix.name }}" --parallel 4
|
||||||
- name: Run sanitizer-safe suites
|
- name: Upload the build (${{ matrix.name }})
|
||||||
env:
|
uses: actions/upload-artifact@v3
|
||||||
ASAN_OPTIONS: detect_leaks=1
|
with:
|
||||||
UBSAN_OPTIONS: print_stacktrace=1
|
name: vbs-build-${{ matrix.name }}
|
||||||
|
path: |
|
||||||
|
build/${{ matrix.name }}/bin/
|
||||||
|
build/${{ matrix.name }}/CTestTestfile.cmake
|
||||||
|
build/${{ matrix.name }}/tests/CTestTestfile.cmake
|
||||||
|
build/${{ matrix.name }}/_deps/voidlibrary-src/
|
||||||
|
!build/${{ matrix.name }}/_deps/voidlibrary-src/.git/
|
||||||
|
build/${{ matrix.name }}/libVoidBuild_Sdk.a
|
||||||
|
build/${{ matrix.name }}/compile_commands.json
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: "3 · Test (${{ matrix.name }})"
|
||||||
|
needs: build
|
||||||
|
runs-on: echoion-release-serial
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: debug
|
||||||
|
test_regex: ""
|
||||||
|
- name: relwithdebinfo
|
||||||
|
test_regex: ""
|
||||||
|
- name: asan
|
||||||
|
test_regex: "vbs_sdk_tests|vbs_core_tests"
|
||||||
|
- name: ubsan
|
||||||
|
test_regex: "vbs_sdk_tests|vbs_core_tests"
|
||||||
|
env:
|
||||||
|
ASAN_OPTIONS: detect_leaks=1
|
||||||
|
UBSAN_OPTIONS: print_stacktrace=1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Download the build (${{ matrix.name }})
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: vbs-build-${{ matrix.name }}
|
||||||
|
path: build/${{ matrix.name }}
|
||||||
|
- name: Make the restored binaries executable
|
||||||
|
run: chmod +x "build/${{ matrix.name }}/bin/"*
|
||||||
|
- name: Run CTest (${{ matrix.name }})
|
||||||
run: |
|
run: |
|
||||||
ctest --test-dir build/ci-asan -R "vbs_sdk_tests|vbs_core_tests" --output-on-failure
|
set -o pipefail
|
||||||
- name: Upload sanitizer logs
|
if [ -n "${{ matrix.test_regex }}" ]; then
|
||||||
|
ctest --test-dir "build/${{ matrix.name }}" --output-on-failure \
|
||||||
|
--no-tests=error -R "${{ matrix.test_regex }}" 2>&1 | tee "ctest-${{ matrix.name }}.log"
|
||||||
|
else
|
||||||
|
ctest --test-dir "build/${{ matrix.name }}" --output-on-failure \
|
||||||
|
--no-tests=error 2>&1 | tee "ctest-${{ matrix.name }}.log"
|
||||||
|
fi
|
||||||
|
- name: Benchmark smoke run
|
||||||
|
if: matrix.name == 'debug'
|
||||||
|
run: build/debug/bin/vbs_benchmarks --files 15
|
||||||
|
- name: Upload the test log (${{ matrix.name }})
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: vbs-asan-ubsan-logs
|
name: vbs-test-${{ matrix.name }}
|
||||||
path: build/ci-asan/Testing/**/LastTest.log
|
path: ctest-${{ matrix.name }}.log
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
fuzz-clang:
|
package:
|
||||||
|
name: "4 · Package"
|
||||||
|
needs: test
|
||||||
runs-on: echoion-release-serial
|
runs-on: echoion-release-serial
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install Clang
|
- name: Download the RelWithDebInfo build
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: vbs-build-relwithdebinfo
|
||||||
|
path: build/relwithdebinfo
|
||||||
|
- name: Make the restored binaries executable
|
||||||
|
run: chmod +x build/relwithdebinfo/bin/*
|
||||||
|
- name: Package the binaries, the SDK and the source
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
set -eu
|
||||||
apt-get install -y clang || sudo apt-get install -y clang
|
ref="${GITHUB_REF_NAME}"
|
||||||
- name: Configure (Debug, Ninja)
|
case "${ref}" in
|
||||||
run: |
|
v*) label="${ref}" ;;
|
||||||
cmake -S . -B build/ci-fuzz -G Ninja \
|
*) label="dev-$(printf '%s' "${GITHUB_SHA}" | cut -c1-7)" ;;
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
esac
|
||||||
-DCMAKE_CXX_COMPILER=g++
|
stage="$(mktemp -d)"
|
||||||
- name: Build vbs (for the VoidLibrary headers)
|
mkdir -p "${stage}/bin" "${stage}/include" "${stage}/lib" dist
|
||||||
run: cmake --build build/ci-fuzz --target vbs --parallel 4
|
cp build/relwithdebinfo/bin/vbs build/relwithdebinfo/bin/vbs-registry "${stage}/bin/"
|
||||||
- name: Fuzz the header-only parsers for 60 seconds
|
cp -r include/Void "${stage}/include/"
|
||||||
env:
|
cp build/relwithdebinfo/libVoidBuild_Sdk.a "${stage}/lib/"
|
||||||
VOID_INCLUDE_DIR: ${{ github.workspace }}/build/ci-fuzz/_deps/voidlibrary-src/include
|
cp README.md LICENSE "${stage}/"
|
||||||
FUZZ_OUT: ${{ github.workspace }}/build/fuzz
|
tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \
|
||||||
run: bash fuzz/run.sh 60
|
-czf "dist/vbs-${label}-linux-x86_64.tar.gz" -C "${stage}" .
|
||||||
- name: Upload the fuzz corpus
|
build/relwithdebinfo/bin/vbs pack --project . --output "dist/vbs-${label}-source.tar"
|
||||||
if: always()
|
rm -f dist/SHA256SUMS
|
||||||
|
(cd dist && sha256sum ./* > SHA256SUMS)
|
||||||
|
ls -l dist/
|
||||||
|
- name: Upload the packages
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: vbs-fuzz-corpus
|
name: vbs-packages
|
||||||
path: build/fuzz/corpus
|
path: dist/
|
||||||
retention-days: 14
|
retention-days: 30
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: "5 · Release"
|
||||||
|
needs: package
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish == 'true'
|
||||||
|
runs-on: echoion-release-serial
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Download the packages
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: vbs-packages
|
||||||
|
path: dist
|
||||||
|
- name: Verify the tag matches the project version
|
||||||
|
run: |
|
||||||
|
tag="${GITHUB_REF_NAME}"
|
||||||
|
version="$(sed -nE 's/^project\(VoidBuildSystem VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)"
|
||||||
|
echo "tag=${tag} project version=${version}"
|
||||||
|
case "${tag}" in
|
||||||
|
v*) ;;
|
||||||
|
*) echo "not a release tag (${tag}); skipping the version check" ; exit 0 ;;
|
||||||
|
esac
|
||||||
|
if [ "${tag#v}" != "${version}" ]; then
|
||||||
|
echo "tag ${tag} does not match the project version ${version}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- name: Publish the Gitea release
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
tag="${GITHUB_REF_NAME}"
|
||||||
|
case "${tag}" in
|
||||||
|
v*) ;;
|
||||||
|
*) echo "not a release tag (${tag}); skipping the release upload" ; exit 0 ;;
|
||||||
|
esac
|
||||||
|
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||||
|
body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")"
|
||||||
|
payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \
|
||||||
|
"${tag}" "${tag}" "${body}")"
|
||||||
|
extract_id() {
|
||||||
|
python3 -c 'import json,sys; s=sys.stdin.read().strip(); print(json.loads(s).get("id","") if s else "")' 2>/dev/null || true
|
||||||
|
}
|
||||||
|
# The release may already exist (e.g. created by hand for the tag): fall back to it.
|
||||||
|
created="$(curl -sS -X POST -H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" -d "${payload}" "${api}/releases" || true)"
|
||||||
|
release_id="$(printf '%s' "${created}" | extract_id)"
|
||||||
|
if [ -z "${release_id}" ]; then
|
||||||
|
existing="$(curl -sS -H "Authorization: token ${TOKEN}" \
|
||||||
|
"${api}/releases/tags/${tag}" || true)"
|
||||||
|
release_id="$(printf '%s' "${existing}" | extract_id)"
|
||||||
|
fi
|
||||||
|
test -n "${release_id}"
|
||||||
|
for file in dist/*; do
|
||||||
|
name="$(basename "${file}")"
|
||||||
|
curl -fsS -X POST -H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@${file}" "${api}/releases/${release_id}/assets?name=${name}" >/dev/null
|
||||||
|
echo "uploaded ${name}"
|
||||||
|
done
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
# VoidBuildSystem release (Gitea Actions).
|
|
||||||
#
|
|
||||||
# Triggered by a `v*` tag (or manually). Builds a Release configuration, runs the full suite,
|
|
||||||
# packages binaries, the SDK and the deterministic source archive, uploads them as CI
|
|
||||||
# artifacts, and creates (or updates) the Gitea release with the same files attached.
|
|
||||||
#
|
|
||||||
# Runner: `echoion-release-serial` - the GCC 16.1.0 builder container. The release upload
|
|
||||||
# uses the automatically provided GITHUB_TOKEN with repository write access.
|
|
||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ["v*"]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
runs-on: echoion-release-serial
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Check the toolchain
|
|
||||||
run: |
|
|
||||||
g++ --version | head -1
|
|
||||||
major="$(g++ -dumpversion | cut -d. -f1)"
|
|
||||||
if [ "${major:-0}" -lt 16 ]; then
|
|
||||||
echo "GCC 16 or newer is required for C++26 (found ${major:-unknown})" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Verify the tag matches the project version
|
|
||||||
run: |
|
|
||||||
tag="${GITHUB_REF_NAME}"
|
|
||||||
version="$(sed -nE 's/^project\(VoidBuildSystem VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)"
|
|
||||||
echo "tag=${tag} project version=${version}"
|
|
||||||
case "${tag}" in
|
|
||||||
v*) ;;
|
|
||||||
*) echo "not a release tag (${tag}); skipping the version check" ; exit 0 ;;
|
|
||||||
esac
|
|
||||||
if [ "${tag#v}" != "${version}" ]; then
|
|
||||||
echo "tag ${tag} does not match the project version ${version}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Configure (Release, Ninja)
|
|
||||||
run: |
|
|
||||||
cmake -S . -B build/release -G Ninja \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_CXX_COMPILER=g++ \
|
|
||||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build/release --parallel 4
|
|
||||||
- name: Run the full suite
|
|
||||||
run: |
|
|
||||||
set -o pipefail
|
|
||||||
ctest --test-dir build/release --output-on-failure 2>&1 | tee ctest-release.log
|
|
||||||
- name: Package binaries, SDK and source
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
tag="${GITHUB_REF_NAME}"
|
|
||||||
stage="$(mktemp -d)"
|
|
||||||
mkdir -p "${stage}/bin" "${stage}/include" "${stage}/lib" dist
|
|
||||||
cp build/release/bin/vbs build/release/bin/vbs-registry "${stage}/bin/"
|
|
||||||
cp -r include/Void "${stage}/include/"
|
|
||||||
cp build/release/libVoidBuild_Sdk.a "${stage}/lib/" 2>/dev/null || \
|
|
||||||
find build/release -name 'libVoidBuild_Sdk.a' -exec cp {} "${stage}/lib/" \;
|
|
||||||
cp README.md "${stage}/"
|
|
||||||
tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \
|
|
||||||
-czf "dist/vbs-${tag}-linux-x86_64.tar.gz" -C "${stage}" .
|
|
||||||
build/release/bin/vbs pack --project . --output "dist/vbs-${tag}-source.tar"
|
|
||||||
cp ctest-release.log dist/
|
|
||||||
sha256sum dist/* > dist/SHA256SUMS
|
|
||||||
ls -l dist/
|
|
||||||
- name: Upload release artifacts
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: vbs-release-${{ github.ref_name }}
|
|
||||||
path: dist/
|
|
||||||
retention-days: 30
|
|
||||||
- name: Publish the Gitea release
|
|
||||||
if: success()
|
|
||||||
env:
|
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
tag="${GITHUB_REF_NAME}"
|
|
||||||
case "${tag}" in
|
|
||||||
v*) ;;
|
|
||||||
*) echo "not a release tag (${tag}); skipping the release upload" ; exit 0 ;;
|
|
||||||
esac
|
|
||||||
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
||||||
body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")"
|
|
||||||
payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \
|
|
||||||
"${tag}" "${tag}" "${body}")"
|
|
||||||
extract_id() {
|
|
||||||
python3 -c 'import json,sys; s=sys.stdin.read().strip(); print(json.loads(s).get("id","") if s else "")' 2>/dev/null || true
|
|
||||||
}
|
|
||||||
# The release may already exist (e.g. created by hand for the tag): fall back to it.
|
|
||||||
created="$(curl -sS -X POST -H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" -d "${payload}" "${api}/releases" || true)"
|
|
||||||
release_id="$(printf '%s' "${created}" | extract_id)"
|
|
||||||
if [ -z "${release_id}" ]; then
|
|
||||||
existing="$(curl -sS -H "Authorization: token ${TOKEN}" \
|
|
||||||
"${api}/releases/tags/${tag}" || true)"
|
|
||||||
release_id="$(printf '%s' "${existing}" | extract_id)"
|
|
||||||
fi
|
|
||||||
test -n "${release_id}"
|
|
||||||
for file in dist/*; do
|
|
||||||
name="$(basename "${file}")"
|
|
||||||
curl -fsS -X POST -H "Authorization: token ${TOKEN}" \
|
|
||||||
-F "attachment=@${file}" "${api}/releases/${release_id}/assets?name=${name}" >/dev/null
|
|
||||||
echo "uploaded ${name}"
|
|
||||||
done
|
|
||||||
Reference in new issue
Block a user