From 5745db97f1163384c396423d00e45b18703b78b6 Mon Sep 17 00:00:00 2001 From: Marvin Vogt Date: Sun, 15 Sep 2024 14:15:02 +0200 Subject: [PATCH] Add build just recipe and use it in CI (#115) --- .github/workflows/build.yml | 7 +++++-- justfile | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af617a3..b3b917a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,12 +19,15 @@ jobs: - uses: astral-sh/setup-uv@v2 with: enable-cache: true - - name: Build - run: uv build + - uses: extractions/setup-just@v2 + + - run: just build + - name: Attest Build Provenance uses: actions/attest-build-provenance@v1 with: subject-path: dist/anycastd-* + - name: Upload Build Artifacts run: >- gh release upload "${GITHUB_REF_NAME}" diff --git a/justfile b/justfile index 9d0d839..01e1e3a 100644 --- a/justfile +++ b/justfile @@ -28,5 +28,23 @@ test $COV=env("CI", "false") $FRR_VERSION=FRR_LATEST_MAJOR_VERSION: uv run pytest tests ${args[@]} if [ $COV = "true" ]; then - uv run coverage xml + uv run coverage xml fi + +# Build sdist and wheel +build: + #!/usr/bin/env bash + set -euxo pipefail + + # Validate version in pyproject.toml matches that of the git tag if running in CI + if [ ! -z ${CI+x} ]; then + PROJECT_VERSION="$(grep -Po '(?<=^version = ").*(?=")' pyproject.toml)" + GIT_TAG="$(git describe --exact-match --tags)" + + if [ ! $PROJECT_VERSION == ${GIT_TAG:1} ]; then + echo Project version $PROJECT_VERSION does not match git tag $GIT_TAG + exit 1 + fi + fi + + uv build