Skip to content

Commit 96c151e

Browse files
JongChernclaude
andcommitted
DEV-1359: a Java API release opens a driver-bump PR in ShimmerAndroidAPI
New job update-android, modelled on update-matlab: on a real release, after the release job, it moves the default driver version in ShimmerAndroidAPI's ShimmerAndroidInstrumentDriver/build.gradle to the new one on a driver_<version> branch and opens a PR. The PR lists the steps that stay manual: check the driver changes since the last pin for parser, CRC or ACK fixes to port to Shimmer.java, run the Android HIL at master's new commit after merging, then run Release Android API. It skips if master is already on that version or the branch or PR exists, and links the PR in the step summary. Needs a new secret, ANDROID_REPO_TOKEN: a fine-grained token for ShimmerResearch/ShimmerAndroidAPI with Contents and Pull requests read/write. Without it the job stops with an error, as update-matlab does. How to release step 3, the run summary's Next line and AGENTS.md now describe the Android steps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 97acd19 commit 96c151e

2 files changed

Lines changed: 104 additions & 5 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# One-click release of the Java API: GitHub Packages, a GitHub Release, and the MATLAB jar.
1+
# One-click release of the Java API: GitHub Packages, a GitHub Release, the MATLAB jar, and a PR moving
2+
# ShimmerAndroidAPI to the new driver.
23
#
34
# How to release
45
# 0. On the bench, at the commit to release: tools/hil/run-java-hil.ps1 -Report (tools/hil/README.md).
@@ -8,7 +9,12 @@
89
# patch after the last API_v release (0.11.8_beta -> 0.11.9_beta), or type one.
910
# 2. Run a MATLAB example on a Shimmer3 and a Shimmer3R with the ShimmerJavaClass.jar PR it opens in
1011
# Shimmer-MATLAB-ID, then merge it. Merging publishes a MATLAB API release (that repo's release.yml).
11-
# 3. Run "Release Android API" in ShimmerAndroidAPI, which builds against this version by default.
12+
# 3. Android: the PR it opens in ShimmerAndroidAPI moves the default driver pin to this version, and
13+
# its CI runs the unit tests and builds every example against it. Check the driver changes since
14+
# the last pin for parser, CRC or ACK fixes: Android's Shimmer.java has its own Bluetooth stream
15+
# parser, so those must be ported by hand. Merge it, run tools/hil/run-android-hil.ps1 -Report
16+
# -DriverVersion <version> on the bench at master's new commit, then run "Release Android API",
17+
# which builds against this version by default.
1218
#
1319
# The version is not kept in the source. The build files read it from -PreleaseVersion, which this
1420
# workflow passes, and say 'local' otherwise; the API_v tags record what was released.
@@ -28,6 +34,11 @@
2834
# update-matlab opens a PR in Shimmer-MATLAB-ID replacing libs/ShimmerJavaClass.jar; merging it
2935
# publishes a MATLAB API release. Needs the MATLAB_REPO_TOKEN secret: a fine-grained
3036
# token for ShimmerResearch/Shimmer-MATLAB-ID with Contents and Pull requests read/write.
37+
# update-android opens a PR in ShimmerAndroidAPI moving the default driver version in
38+
# ShimmerAndroidInstrumentDriver/build.gradle to this one, listing the Android steps.
39+
# The Android release stays manual: it needs a passing bench test on its own commit.
40+
# Needs the ANDROID_REPO_TOKEN secret: a fine-grained token for
41+
# ShimmerResearch/ShimmerAndroidAPI with Contents and Pull requests read/write.
3142
#
3243
# A failed job can be re-run on its own with "Re-run failed jobs"; the jobs before it are not
3344
# repeated. A failed publish can leave some of the three versions in GitHub Packages: delete those
@@ -347,7 +358,7 @@ jobs:
347358
echo "- Release: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG"
348359
echo "- Packages: com.shimmerresearch:shimmerdriver, shimmerbluetoothmanager and shimmerdriverpc at $VERSION"
349360
echo "- ${HIL:-No hardware test result}"
350-
echo "- Next: run a MATLAB example on a Shimmer3 and a Shimmer3R and merge the MATLAB PR, which publishes a MATLAB API release; then run Release Android API in ShimmerAndroidAPI; it builds against $VERSION unless you pick another driver version."
361+
echo "- Next: run a MATLAB example on a Shimmer3 and a Shimmer3R and merge the MATLAB PR, which publishes a MATLAB API release. For Android, follow the steps in the ShimmerAndroidAPI driver PR: port any parser, CRC or ACK fix to Shimmer.java, merge, run the Android HIL with -DriverVersion $VERSION at master's new commit, then run Release Android API."
351362
} >> "$GITHUB_STEP_SUMMARY"
352363
353364
update-matlab:
@@ -414,3 +425,85 @@ jobs:
414425
Opened by the [Release Java API run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID).")
415426
echo "Opened $url"
416427
echo "- MATLAB PR: $url" >> "$GITHUB_STEP_SUMMARY"
428+
429+
# Only the default pin moves here. Release Android API already builds against the newest Java
430+
# release; this PR is so ShimmerAndroidAPI's CI tries the new driver, and so the Android steps
431+
# that follow a Java release are written down where they are done.
432+
update-android:
433+
needs: [build, release]
434+
runs-on: ubuntu-latest
435+
timeout-minutes: 10
436+
permissions: {} # writes to ShimmerAndroidAPI with ANDROID_REPO_TOKEN, not this repo's token
437+
env:
438+
VERSION: ${{ needs.build.outputs.version }}
439+
TAG: ${{ needs.build.outputs.tag }}
440+
ANDROID_REPO: ShimmerResearch/ShimmerAndroidAPI
441+
BRANCH: driver_${{ needs.build.outputs.version }}
442+
PIN_FILE: ShimmerAndroidInstrumentDriver/build.gradle
443+
HAS_TOKEN: ${{ secrets.ANDROID_REPO_TOKEN != '' }}
444+
steps:
445+
- name: Check for ANDROID_REPO_TOKEN
446+
if: env.HAS_TOKEN != 'true'
447+
run: |
448+
echo "::error::Secret ANDROID_REPO_TOKEN is not set, so the ShimmerAndroidAPI PR cannot be opened. Add a fine-grained token for $ANDROID_REPO (Contents and Pull requests: read/write) as a repo secret, then re-run this job."
449+
exit 1
450+
451+
# Credentials stay persisted here on purpose: the git push below uses them. Nothing else runs
452+
# in this job.
453+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
454+
with:
455+
repository: ${{ env.ANDROID_REPO }}
456+
token: ${{ secrets.ANDROID_REPO_TOKEN }}
457+
path: android
458+
459+
- name: Open the PR moving the default driver to this version
460+
env:
461+
GH_TOKEN: ${{ secrets.ANDROID_REPO_TOKEN }}
462+
working-directory: android
463+
run: |
464+
existing=$(gh pr list --repo "$ANDROID_REPO" --head "$BRANCH" --state open --json url --jq '.[0].url // ""')
465+
if [ -n "$existing" ]; then
466+
echo "PR already open: $existing"
467+
echo "- Android PR: $existing" >> "$GITHUB_STEP_SUMMARY"
468+
exit 0
469+
fi
470+
# The default is the one line: def shimmerDriverVersion = findProperty('driverVersion') ?: '<version>'
471+
old=$(sed -n "s/.*findProperty('driverVersion') ?: '\([^']*\)'.*/\1/p" "$PIN_FILE")
472+
if [ -z "$old" ] || [ "$(wc -l <<<"$old")" -ne 1 ]; then
473+
echo "::error::$ANDROID_REPO's $PIN_FILE no longer has exactly one line like findProperty('driverVersion') ?: '0.11.11_beta'. Update this job to match it."
474+
exit 1
475+
fi
476+
if [ "$old" = "$VERSION" ]; then
477+
echo "$PIN_FILE already defaults to $VERSION; no PR needed."
478+
echo "- Android: master already builds against $VERSION; no PR needed." >> "$GITHUB_STEP_SUMMARY"
479+
exit 0
480+
fi
481+
if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null; then
482+
echo "::warning::Branch $BRANCH already exists in $ANDROID_REPO with no open PR, so this job leaves it alone. Open a PR from it, or delete it and re-run this job."
483+
echo "- Android: branch $BRANCH already exists with no open PR. Open a PR from it, or delete it and re-run this job." >> "$GITHUB_STEP_SUMMARY"
484+
exit 0
485+
fi
486+
# VERSION is checked against ^[0-9]+\.[0-9]+\.[0-9]+[A-Za-z0-9_.-]*$ in build, so it is safe in sed.
487+
sed -i "s/\(findProperty('driverVersion') ?: '\)[^']*'/\1$VERSION'/" "$PIN_FILE"
488+
git config user.name "github-actions[bot]"
489+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
490+
git switch -c "$BRANCH"
491+
git add "$PIN_FILE"
492+
git commit -m "Build against Shimmer Java API $VERSION by default" \
493+
-m "Moves the default driver version in $PIN_FILE from $old to $VERSION. Opened by $GITHUB_REPOSITORY's Release workflow for $TAG ($GITHUB_SHA)."
494+
git push origin "HEAD:refs/heads/$BRANCH"
495+
url=$(gh pr create --repo "$ANDROID_REPO" --base master --head "$BRANCH" \
496+
--title "Build against Shimmer Java API $VERSION by default" \
497+
--body "Moves the default driver version in \`$PIN_FILE\` from $old to $VERSION, released as [$TAG]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG). CI and local builds use the default. Release Android API builds against the newest Java release whether or not this merges, so this PR is the check that the library and the examples still work with it.
498+
499+
Before merging:
500+
- [ ] CI passes: the library's unit tests and every example, built against $VERSION.
501+
- [ ] Check the [driver changes since $old]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/API_v$old...$TAG) for Bluetooth stream parser, CRC or ACK fixes. \`Shimmer.java\` has its own copy of that parser, so those fixes never reach it through this pin: port each one by hand. AGENTS.md explains why (DEV-1148 ported DEV-1147's fix).
502+
503+
After merging:
504+
- [ ] On the bench, at master's new commit: \`tools/hil/run-android-hil.ps1 -Report -DriverVersion $VERSION\`. The \`android-hil (driver $VERSION)\` status it posts is per commit, so a run on this branch does not count for the release.
505+
- [ ] Run **Release Android API** with \`driver_version\` $VERSION, or blank for the newest Java release.
506+
507+
Opened by the [Release Java API run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID).")
508+
echo "Opened $url"
509+
echo "- Android PR: $url" >> "$GITHUB_STEP_SUMMARY"

‎AGENTS.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ and need no uprev PR:
2929
`Shimmer-MATLAB-ID/libs/ShimmerJavaClass.jar` (needs the `MATLAB_REPO_TOKEN` secret). Before
3030
merging it, run a MATLAB example on a Shimmer3 and a Shimmer3R; MATLAB cannot run in CI. Merging
3131
publishes a MATLAB API release (Shimmer-MATLAB-ID's `release.yml`).
32-
3. Run `ShimmerAndroidAPI`'s own Release workflow, which builds against the newest Java release unless
33-
told otherwise.
32+
3. It also opens a PR in `ShimmerAndroidAPI` moving the default driver version in
33+
`ShimmerAndroidInstrumentDriver/build.gradle` to this one (needs the `ANDROID_REPO_TOKEN` secret),
34+
so that repo's CI runs its unit tests and builds every example against it. The PR lists the steps
35+
that stay manual. Android's `Shimmer.java` has its own Bluetooth stream parser, so a parser, CRC or
36+
ACK fix in this release must be ported there by hand (see `ShimmerAndroidAPI`'s AGENTS.md). After
37+
merging, run the Android HIL at master's new commit, then `ShimmerAndroidAPI`'s own Release
38+
workflow, which builds against the newest Java release unless told otherwise. That release cannot
39+
be automatic: its gate needs a passing bench run on its exact commit and driver.
3440

3541
The version is not stored in the source: the three publishing blocks read `-PreleaseVersion`, which
3642
the workflow passes, and fall back to `local`. The `API_v` tags are the record of what was released.

0 commit comments

Comments
 (0)