ci: guard the version file and publish a prebuilt release asset
A `version` file drifting from the latest tag makes the self-update check report a phantom update, and installed apps without a toolchain need a binary. Fail the tests job on a version/tag mismatch, and attach a prebuilt archive to each release as a best effort so a failed build never blocks the release. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
54bff16369
commit
cddc5f956a
2 files changed
+94
-2
No files matched your search
@@ -4,6 +4,13 @@
|
|||||||
# Creates a Gitea release tagged with the new version — but ONLY if the
|
# Creates a Gitea release tagged with the new version — but ONLY if the
|
||||||
# version in `version` differs from the latest released tag.
|
# version in `version` differs from the latest released tag.
|
||||||
#
|
#
|
||||||
|
# The release also uploads a prebuilt binary archive
|
||||||
|
# (PacManager-<version>-x86_64.tar.gz with the binary, version file and
|
||||||
|
# plugins) so installed apps without a build toolchain can self-update
|
||||||
|
# WITHOUT recompiling. UpdateManager uses it as a fallback when git/cmake/a
|
||||||
|
# compiler are unavailable; otherwise it clones the repo and rebuilds. The
|
||||||
|
# upload is best-effort, so a failed build never blocks the release itself.
|
||||||
|
#
|
||||||
# No secret is required: `secrets.GITEA_TOKEN` is the built-in automatic
|
# No secret is required: `secrets.GITEA_TOKEN` is the built-in automatic
|
||||||
# token provided by Gitea on every run. The `permissions: contents: write`
|
# token provided by Gitea on every run. The `permissions: contents: write`
|
||||||
# block below asks for write access to contents and releases, so the release
|
# block below asks for write access to contents and releases, so the release
|
||||||
@@ -56,6 +63,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
if: steps.check.outputs.new == 'true'
|
if: steps.check.outputs.new == 'true'
|
||||||
|
id: create
|
||||||
env:
|
env:
|
||||||
# Built-in automatic token, no secret to configure. The
|
# Built-in automatic token, no secret to configure. The
|
||||||
# `permissions` block at the top grants it write access to
|
# `permissions` block at the top grants it write access to
|
||||||
@@ -69,7 +77,7 @@ jobs:
|
|||||||
`version` file was bumped.
|
`version` file was bumped.
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
curl -sS -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \
|
RESP=$(curl -sS -X POST "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @- <<JSON
|
-d @- <<JSON
|
||||||
@@ -80,3 +88,58 @@ jobs:
|
|||||||
"body": "${BODY}"
|
"body": "${BODY}"
|
||||||
}
|
}
|
||||||
JSON
|
JSON
|
||||||
|
)
|
||||||
|
echo "${RESP}"
|
||||||
|
ID=$(echo "${RESP}" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2)
|
||||||
|
echo "release_id=${ID}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build prebuilt binary archive
|
||||||
|
if: steps.check.outputs.new == 'true'
|
||||||
|
id: build
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.value }}"
|
||||||
|
if command -v pacman >/dev/null 2>&1; then
|
||||||
|
sudo pacman -S --noconfirm --needed git cmake gcc make qt6-base
|
||||||
|
elif command -v apt-get >/dev/null 2>&1; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y git cmake g++ make qt6-base-dev
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
sudo dnf install -y git cmake gcc-c++ make qt6-qtbase-devel
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager — skipping prebuilt archive"
|
||||||
|
echo "ok=false" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build -j$(nproc)
|
||||||
|
STAGE="pacmanager-dist"
|
||||||
|
rm -rf "${STAGE}" && mkdir -p "${STAGE}/bin" "${STAGE}/plugins"
|
||||||
|
cp build/PacManager "${STAGE}/bin/"
|
||||||
|
cp version "${STAGE}/bin/"
|
||||||
|
if ls build/plugins/*.so >/dev/null 2>&1; then
|
||||||
|
cp build/plugins/*.so "${STAGE}/plugins/"
|
||||||
|
fi
|
||||||
|
# Layout consumed by UpdateManager's prebuilt path: bin/PacManager,
|
||||||
|
# bin/version and plugins/ (unpacked next to the running executable,
|
||||||
|
# wherever it lives).
|
||||||
|
ARCHIVE="PacManager-${VERSION}-x86_64.tar.gz"
|
||||||
|
tar czf "${ARCHIVE}" -C "${STAGE}" bin plugins
|
||||||
|
echo "archive=${ARCHIVE}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "ok=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Upload prebuilt archive to release
|
||||||
|
if: steps.check.outputs.new == 'true' && steps.build.outputs.ok == 'true'
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: |
|
||||||
|
ARCHIVE="${{ steps.build.outputs.archive }}"
|
||||||
|
RELEASE_ID="${{ steps.create.outputs.release_id }}"
|
||||||
|
if [ -z "${RELEASE_ID}" ]; then
|
||||||
|
echo "No release id — skipping upload"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
curl -sS -X POST \
|
||||||
|
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/${RELEASE_ID}/assets?name=$(basename ${ARCHIVE})" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/gzip" \
|
||||||
|
--data-binary "@${ARCHIVE}" || echo "Asset upload failed — release still valid without prebuilt binary"
|
||||||
@@ -2,7 +2,9 @@
|
|||||||
#
|
#
|
||||||
# Dedicated test workflow: builds the application and runs the full test suite
|
# Dedicated test workflow: builds the application and runs the full test suite
|
||||||
# (ctest) on every push and pull request. Kept separate from the release
|
# (ctest) on every push and pull request. Kept separate from the release
|
||||||
# workflow so a failing test never blocks a release.
|
# workflow so a failing test never blocks a release. Also guards the
|
||||||
|
# `version` file: it must match the latest git tag (if any), otherwise the
|
||||||
|
# self-update check would report a phantom update.
|
||||||
|
|
||||||
name: tests
|
name: tests
|
||||||
|
|
||||||
@@ -12,6 +14,33 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
version-guard:
|
||||||
|
runs-on: linux
|
||||||
|
steps:
|
||||||
|
- name: Checkout with full history and tags
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- name: Check version file matches latest tag (when tags exist)
|
||||||
|
run: |
|
||||||
|
VERSION=$(tr -d ' \n' < version)
|
||||||
|
echo "version file: ${VERSION}"
|
||||||
|
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || true)
|
||||||
|
if [ -z "${LATEST}" ]; then
|
||||||
|
echo "No tags yet — skipping version guard"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# Tags are like v1.3.1 / V1.3.1 ; the file holds 1.3.1
|
||||||
|
NORMALIZED=$(echo "${LATEST}" | sed -E 's/^[vV]//')
|
||||||
|
echo "latest tag: ${LATEST} (normalized: ${NORMALIZED})"
|
||||||
|
if [ "${VERSION}" != "${NORMALIZED}" ]; then
|
||||||
|
echo "::error::version file (${VERSION}) does not match latest tag ${LATEST} (expected ${NORMALIZED}). Bump the version file before tagging."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "version file matches latest tag"
|
||||||
|
|
||||||
build-test:
|
build-test:
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
Reference in new issue
Block a user