|
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. |
2 | 3 | # |
3 | 4 | # How to release |
4 | 5 | # 0. On the bench, at the commit to release: tools/hil/run-java-hil.ps1 -Report (tools/hil/README.md). |
|
8 | 9 | # patch after the last API_v release (0.11.8_beta -> 0.11.9_beta), or type one. |
9 | 10 | # 2. Run a MATLAB example on a Shimmer3 and a Shimmer3R with the ShimmerJavaClass.jar PR it opens in |
10 | 11 | # 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. |
12 | 18 | # |
13 | 19 | # The version is not kept in the source. The build files read it from -PreleaseVersion, which this |
14 | 20 | # workflow passes, and say 'local' otherwise; the API_v tags record what was released. |
|
28 | 34 | # update-matlab opens a PR in Shimmer-MATLAB-ID replacing libs/ShimmerJavaClass.jar; merging it |
29 | 35 | # publishes a MATLAB API release. Needs the MATLAB_REPO_TOKEN secret: a fine-grained |
30 | 36 | # 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. |
31 | 42 | # |
32 | 43 | # A failed job can be re-run on its own with "Re-run failed jobs"; the jobs before it are not |
33 | 44 | # repeated. A failed publish can leave some of the three versions in GitHub Packages: delete those |
@@ -347,7 +358,7 @@ jobs: |
347 | 358 | echo "- Release: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG" |
348 | 359 | echo "- Packages: com.shimmerresearch:shimmerdriver, shimmerbluetoothmanager and shimmerdriverpc at $VERSION" |
349 | 360 | 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." |
351 | 362 | } >> "$GITHUB_STEP_SUMMARY" |
352 | 363 |
|
353 | 364 | update-matlab: |
@@ -414,3 +425,85 @@ jobs: |
414 | 425 | Opened by the [Release Java API run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID).") |
415 | 426 | echo "Opened $url" |
416 | 427 | 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" |
0 commit comments