mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-20 15:13:47 +01:00
Rewrite of #1713. .gitlab-ci.yml's .setup-bun anchor and scripts/ubicloud/setup-free-suite.sh still piped https://bun.sh/install into bash. Both now download the bun-v$BUN_VERSION linux-x64 release zip, check it against the same SHA-256 Dockerfile.ci uses (#1706) before unzipping, install it to ~/.bun/bin and assert `bun --version`. test/ci-image-cli-pin.test.ts runs curlPipedToShell over both files and binds their hash and BUN_VERSION to Dockerfile.ci's amd64 arm and package.json's engines floor, so a Bun bump has to move all of them together. Verified by running the GitLab anchor in debian:stable-slim (bash and sh) and the Ubicloud block in a temp HOME. Co-authored-by: Zee Zheng <228040220+spacegeologist@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
83 lines
3.1 KiB
YAML
83 lines
3.1 KiB
YAML
# GitLab CI parity for workspace-aware ship.
|
|
# Mirrors .github/workflows/version-gate.yml and pr-title-sync.yml.
|
|
# Projects that mirror to GitLab get the same protection as GitHub.
|
|
|
|
stages:
|
|
- check
|
|
|
|
variables:
|
|
BUN_VERSION: "1.4.2"
|
|
|
|
.setup-bun: &setup-bun
|
|
- apt-get update -qq && apt-get install -qq -y curl jq git unzip
|
|
# The exact release archive, verified by SHA-256 before it is unpacked, as
|
|
# in .github/docker/Dockerfile.ci. test/ci-image-cli-pin.test.ts keeps the
|
|
# hash and BUN_VERSION equal to that file's linux-x64 arm.
|
|
- |
|
|
curl --retry 5 --retry-delay 5 --retry-connrefused -fsSL \
|
|
"https://github.com/oven-sh/bun/releases/download/bun-v$BUN_VERSION/bun-linux-x64.zip" -o /tmp/bun.zip
|
|
echo "36368faef7527875d5ffa52e53cd48021741f2a83eb6208a8dd64068d422a913 /tmp/bun.zip" | sha256sum -c -
|
|
unzip -q /tmp/bun.zip -d /tmp/bun
|
|
install -D -m 0755 /tmp/bun/bun-linux-x64/bun "$HOME/.bun/bin/bun"
|
|
rm -rf /tmp/bun /tmp/bun.zip
|
|
- export PATH="$HOME/.bun/bin:$PATH"
|
|
- test "$(bun --version)" = "$BUN_VERSION"
|
|
|
|
version-gate:
|
|
stage: check
|
|
image: debian:stable-slim
|
|
rules:
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
changes:
|
|
- VERSION
|
|
- CHANGELOG.md
|
|
- package.json
|
|
script:
|
|
- *setup-bun
|
|
- PR_VERSION=$(cat VERSION | tr -d '[:space:]')
|
|
- BASE_VERSION=$(git show "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME:VERSION" 2>/dev/null | tr -d '[:space:]' || echo "0.0.0.0")
|
|
- LEVEL=$(bun run scripts/detect-bump.ts "$BASE_VERSION" "$PR_VERSION")
|
|
# Util fail-open: on non-zero exit, emit offline marker
|
|
- |
|
|
set +e
|
|
bun run bin/gstack-next-version \
|
|
--base "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" \
|
|
--bump "$LEVEL" \
|
|
--current-version "$BASE_VERSION" \
|
|
--workspace-root null \
|
|
--exclude-pr "$CI_MERGE_REQUEST_IID" \
|
|
> next.json
|
|
RC=$?
|
|
if [ "$RC" != "0" ] || [ ! -s next.json ]; then
|
|
echo '{"offline":true}' > next.json
|
|
echo "WARNING: util exit=$RC — failing open"
|
|
fi
|
|
set -e
|
|
- PR_VERSION="$PR_VERSION" bun run scripts/compare-pr-version.ts next.json "$CI_MERGE_REQUEST_IID"
|
|
|
|
pr-title-sync:
|
|
stage: check
|
|
image: debian:stable-slim
|
|
rules:
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
changes:
|
|
- VERSION
|
|
script:
|
|
- apt-get update -qq && apt-get install -qq -y curl jq git
|
|
- curl -fsSL https://gitlab.com/gitlab-org/cli/-/releases/permalink/latest/downloads/glab_linux_amd64.deb -o glab.deb && dpkg -i glab.deb
|
|
- VERSION=$(cat VERSION | tr -d '[:space:]')
|
|
- TITLE="$CI_MERGE_REQUEST_TITLE"
|
|
- |
|
|
if printf '%s' "$TITLE" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ '; then
|
|
PREFIX=$(printf '%s' "$TITLE" | awk '{print $1}')
|
|
REST=$(printf '%s' "$TITLE" | sed 's/^v[0-9][0-9.]* //')
|
|
if [ "v$VERSION" != "$PREFIX" ]; then
|
|
echo "Rewriting: $PREFIX ... → v$VERSION ..."
|
|
glab mr update "$CI_MERGE_REQUEST_IID" -t "v$VERSION $REST"
|
|
else
|
|
echo "Title already matches v$VERSION; no change."
|
|
fi
|
|
else
|
|
echo "Title does not use v<X.Y.Z.W> prefix — leaving alone."
|
|
fi
|