Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/cd-swift-cua-driver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,24 @@ jobs:
> Supports Apple Silicon (arm64) and Intel (x86_64) — the release tarball contains a universal binary.
generate_release_notes: false
make_latest: true

- name: Bake version into install.sh
if: startsWith(github.ref, 'refs/tags/cua-driver-v')
env:
VERSION: ${{ steps.set_version.outputs.version }}
GH_TOKEN: ${{ github.token }}
run: |
# Fetch main so we update the live branch, not the detached tag HEAD.
git fetch origin main
git checkout -B bake-version origin/main

# Replace the baked version line inside the sentinel block.
sed -i '' \
"s/^CUA_DRIVER_BAKED_VERSION=.*/CUA_DRIVER_BAKED_VERSION=\"${VERSION}\"/" \
libs/cua-driver/scripts/install.sh

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add libs/cua-driver/scripts/install.sh
git commit -m "chore(cua-driver): bake version ${VERSION} into install.sh [skip ci]"
git push origin bake-version:main
14 changes: 13 additions & 1 deletion libs/cua-driver/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,30 @@ for cmd in curl tar; do
done

# --- Resolve release tag ------------------------------------------------
#
# Version is resolved in priority order:
# 1. CUA_DRIVER_VERSION env var (explicit pin)
# 2. BAKED_VERSION below (set automatically by CD after each release — no API call needed)
# 3. GitHub Releases API (fallback; unauthenticated = 60 req/hr per IP)
#
# ~~~ BAKED_VERSION: auto-updated by CD workflow after each release — do not edit ~~~
CUA_DRIVER_BAKED_VERSION="0.1.9"
# ~~~ END_BAKED_VERSION ~~~

if [[ -n "${CUA_DRIVER_VERSION:-}" ]]; then
TAG="${TAG_PREFIX}${CUA_DRIVER_VERSION#v}"
log "using version from CUA_DRIVER_VERSION: $TAG"
elif [[ -n "${CUA_DRIVER_BAKED_VERSION:-}" ]]; then
TAG="${TAG_PREFIX}${CUA_DRIVER_BAKED_VERSION}"
log "latest release: $TAG"
else
log "resolving latest $TAG_PREFIX* release via GitHub API"
# `grep -v cua-driver-rs` is defense-in-depth — the Rust port (cua-driver-rs)
# publishes to the same repo under tag prefix `cua-driver-rs-v*` and the
# current grep regex `cua-driver-v[^"]+` already excludes it (differs at
# position 11: 'r' vs 'v'), but the negation guards against any future
# regex tweak that might accidentally widen the match.
TAG=$(curl -fsSL "https://api.github.com/repos/$REPO/releases?per_page=40" \
TAG=$(curl -fsSL "https://api.github.com/repos/$REPO/releases?per_page=100" \
| grep -Eo '"tag_name":[[:space:]]*"'"${TAG_PREFIX}"'[^"]+"' \
| grep -v 'cua-driver-rs' \
| sed -E 's/.*"'"${TAG_PREFIX}"'([0-9]+[.][0-9]+[.][0-9]+)"/\1/' \
Expand Down
Loading