From 5a0e3d011c0d60f7197548d392979eecee5fd651 Mon Sep 17 00:00:00 2001 From: JongChern Date: Thu, 15 Oct 2026 12:11:38 +0800 Subject: [PATCH 01/10] DEV-1115 Add one-click Release Android API workflow Actions -> "Release Android API" releases the version in the library's publishing block (bumped by the usual uprev PR; master is protected): - warns when the shimmerdriver/shimmerbluetoothmanager pins are older than the newest Java API release, the drift DEV-1115 describes - builds the release .aar and publishes it to GitHub Packages - tags AndroidAPI_v and creates the GitHub Release with the .aar Re-enable the library's publishing block, commented out since Feb 2024 because it read a github.properties file that most checkouts lack. It now reads gpr.user/gpr.key or GITHUB_ACTOR/GITHUB_TOKEN, so a build without credentials still configures, and publishes to ShimmerResearch instead of ShimmerEngineering. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 181 ++++++++++++++++++ .../build.gradle | 15 +- 2 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..16cb516c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,181 @@ +# One-click release of the Android API: GitHub Packages + a GitHub Release. +# +# How to release +# 1. Release the Java API first if the driver changed (its "Release Java API" workflow), then +# merge an uprev PR here that bumps the shimmerdriver/shimmerbluetoothmanager pins in +# ShimmerAndroidInstrumentDriver/build.gradle and the publishing `version` in +# ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle. +# master is protected, so this workflow cannot commit the bump itself. +# 2. Actions -> "Release Android API" -> Run workflow (on master). +# +# One run does, in order, and creates nothing public until the library has built: +# build reads the version from the library's publishing block; fails if AndroidAPI_v +# is already tagged; warns if the driver pins are not the newest Java API release +# (DEV-1115); builds the release .aar; publishes it to GitHub Packages +# release tags AndroidAPI_v on the commit it built and creates the GitHub Release, with +# notes from the previous Android API release and the .aar attached +# +# If only the release job fails, "Re-run failed jobs" re-runs just that job. +# +# Reading the driver from Shimmer-Java-Android-API's GitHub Packages uses this repo's GITHUB_TOKEN. +# If that is refused (401/403 resolving com.shimmerresearch:shimmerdriver), add a classic token +# with read:packages as the PACKAGES_READ_TOKEN secret and it is used instead. +# +# dry_run builds without publishing, from any branch. The workflow also dry-runs on any PR that +# changes this file. + +name: Release Android API + +on: + workflow_dispatch: + inputs: + dry_run: + description: 'Build only; publish nothing' + type: boolean + default: false + pull_request: + paths: + - '.github/workflows/release.yml' + +concurrency: + group: release-android-api + cancel-in-progress: false + +defaults: + run: + working-directory: ShimmerAndroidInstrumentDriver + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + DRY_RUN: ${{ github.event_name != 'workflow_dispatch' || inputs.dry_run }} + # Read by the repositories in the root build.gradle to resolve the driver. + USERNAME: ${{ github.actor }} + TOKEN: ${{ secrets.PACKAGES_READ_TOKEN || github.token }} + outputs: + version: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.tag }} + previous_tag: ${{ steps.version.outputs.previous_tag }} + steps: + - name: Release from master only + if: env.DRY_RUN != 'true' && github.ref != 'refs/heads/master' + working-directory: . + run: | + echo "::error::A release must run on master, not ${GITHUB_REF_NAME}. Tick dry_run to try another branch." + exit 1 + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # tags, to refuse a version that is already released + + - name: Read the version and check the driver pins + id: version + env: + GH_TOKEN: ${{ github.token }} + run: | + lib=ShimmerAndroidInstrumentDriver/build.gradle + VERSION=$(sed -nE "s/^[[:space:]]*version = '([^']+)'.*/\1/p" "$lib") + if [ "$(printf '%s\n' "$VERSION" | grep -c .)" -ne 1 ]; then + echo "::error file=ShimmerAndroidInstrumentDriver/$lib::Expected exactly one publishing version = '...' line" + exit 1 + fi + TAG="AndroidAPI_v$VERSION" + if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then + echo "::error::$TAG already exists. Bump the version with an uprev PR first." + exit 1 + fi + # Earlier releases were tagged v3.2.xBeta, so match those too. + PREVIOUS_TAG=$(gh release list --repo "$GITHUB_REPOSITORY" --limit 200 --json tagName,createdAt \ + --jq '[.[] | select(.tagName | test("^(AndroidAPI_)?v[0-9]"))] | sort_by(.createdAt) | last | .tagName // ""') + + newest=$(gh release list --repo "$GITHUB_REPOSITORY_OWNER/Shimmer-Java-Android-API" --limit 200 --json tagName,createdAt \ + --jq '[.[] | select(.tagName | startswith("API_v"))] | sort_by(.createdAt) | last | .tagName // "" | ltrimstr("API_v")') + pins=$(sed -nE "s/.*name: *'(shimmerdriver|shimmerbluetoothmanager)', *version: *'([^']+)'.*/\1 \2/p" build.gradle) + echo "Driver pins:"; echo "${pins:-}" + echo "Newest Java API release: ${newest:-}" + if [ "$(printf '%s\n' "$pins" | grep -c .)" -ne 2 ]; then + echo "::warning file=ShimmerAndroidInstrumentDriver/build.gradle::Could not read both driver pins, so they were not checked against the newest Java API release." + fi + while read -r name pinned; do + if [ -n "$name" ] && [ -n "$newest" ] && [ "$pinned" != "$newest" ]; then + echo "::warning file=ShimmerAndroidInstrumentDriver/build.gradle::$name is pinned at $pinned, but the newest Java API release is $newest. Driver fixes since then are not in this release." + fi + done <<< "$pins" + + { + echo "version=$VERSION" + echo "tag=$TAG" + echo "previous_tag=$PREVIOUS_TAG" + } >> "$GITHUB_OUTPUT" + echo "Releasing $VERSION as $TAG (notes since ${PREVIOUS_TAG:-the first commit})" + + # AGP 8 needs JDK 17. + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 + + # gradle.properties is gitignored here, so android.useAndroidX (needed for the androidx + # dependencies) is passed on the command line. + - name: Build the release .aar + run: ./gradlew :ShimmerAndroidInstrumentDriver:assembleRelease -Pandroid.useAndroidX=true + + - name: Publish to GitHub Packages + if: env.DRY_RUN != 'true' + env: + GITHUB_TOKEN: ${{ github.token }} + run: ./gradlew :ShimmerAndroidInstrumentDriver:publish -Pandroid.useAndroidX=true + + - name: Collect the release .aar + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + mkdir -p ../release-assets + cp ShimmerAndroidInstrumentDriver/build/outputs/aar/ShimmerAndroidInstrumentDriver-release.aar \ + "../release-assets/shimmerandroidinstrumentdriver-$VERSION.aar" + ls -l ../release-assets + + - uses: actions/upload-artifact@v4 + with: + name: release-assets + path: release-assets/ + if-no-files-found: error + + release: + needs: build + if: github.event_name == 'workflow_dispatch' && !inputs.dry_run + runs-on: ubuntu-latest + permissions: + contents: write # create the tag and the release + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ needs.build.outputs.version }} + TAG: ${{ needs.build.outputs.tag }} + PREVIOUS_TAG: ${{ needs.build.outputs.previous_tag }} + steps: + - uses: actions/download-artifact@v4 + with: + name: release-assets + path: release-assets + + - name: Create the tag and GitHub Release + working-directory: . + run: | + gh release create "$TAG" release-assets/* \ + --repo "$GITHUB_REPOSITORY" \ + --target "$GITHUB_SHA" \ + --title "$TAG" \ + --generate-notes ${PREVIOUS_TAG:+--notes-start-tag "$PREVIOUS_TAG"} + { + echo "### Released Android API $VERSION" + echo "- Release: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG" + echo "- Package: com.shimmerresearch:shimmerandroidinstrumentdriver:$VERSION" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle index 672f4b69..32e270eb 100644 --- a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle @@ -77,7 +77,9 @@ publishing { def getArtificatId = { -> return "ShimmerAndroidInstrumentDriver" // Replace with library name ID } -/* +// Published by the "Release Android API" workflow (.github/workflows/release.yml), which also reads +// the version below: bump it in the uprev PR, then run the workflow. Run assembleRelease before +// publish, because the artifact is the built .aar file. publishing { publications { bar(MavenPublication) { @@ -91,16 +93,17 @@ publishing { repositories { maven { name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/ShimmerEngineering/ShimmerAndroidAPI") + url = uri("https://maven.pkg.github.com/ShimmerResearch/ShimmerAndroidAPI") credentials { - //Create github.properties in root project folder file with gpra.usr=GITHUB_USER_ID & gpra.key=PERSONAL_ACCESS_TOKEN - username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") - password = project.findProperty("gpr.key") ?: System.getenv("TOKEN") + // Locally: gpr.user and gpr.key in GRADLE_USER_HOME/gradle.properties, with a token + // that has write:packages. In the workflow: GITHUB_ACTOR and GITHUB_TOKEN. These are + // kept apart from USERNAME/TOKEN in the root build.gradle, which only need to read. + username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR") + password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") } } } } -*/ dependencies { implementation 'com.google.guava:guava:20.0' implementation 'java3d:vecmath:1.3.1' From 57d1e046de436b85b4069713f0eb1b1bf285756e Mon Sep 17 00:00:00 2001 From: JongChern Date: Thu, 15 Oct 2026 12:12:26 +0800 Subject: [PATCH 02/10] DEV-1115 Refuse a version already released under the older tag spelling Releases before this workflow were tagged AndroidAPI_v3.2.9Beta and v3.2.8Beta, so the AndroidAPI_v check alone would let an un-bumped 3.2.9_beta be released a second time. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16cb516c..33159659 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,8 @@ # 2. Actions -> "Release Android API" -> Run workflow (on master). # # One run does, in order, and creates nothing public until the library has built: -# build reads the version from the library's publishing block; fails if AndroidAPI_v -# is already tagged; warns if the driver pins are not the newest Java API release +# build reads the version from the library's publishing block; fails if that version is +# already tagged (in this or the older v3.2.xBeta form); warns if the driver pins are not the newest Java API release # (DEV-1115); builds the release .aar; publishes it to GitHub Packages # release tags AndroidAPI_v on the commit it built and creates the GitHub Release, with # notes from the previous Android API release and the .aar attached @@ -84,10 +84,15 @@ jobs: exit 1 fi TAG="AndroidAPI_v$VERSION" - if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then - echo "::error::$TAG already exists. Bump the version with an uprev PR first." - exit 1 - fi + # Releases before this workflow were tagged v3.2.8Beta / AndroidAPI_v3.2.9Beta for version + # 3.2.x_beta, so check those spellings too, or an un-bumped version would be released twice. + legacy=${VERSION/_beta/Beta} + for t in "$TAG" "AndroidAPI_v$legacy" "v$legacy"; do + if git rev-parse -q --verify "refs/tags/$t" >/dev/null; then + echo "::error::$VERSION is already released as $t. Bump the version with an uprev PR first." + exit 1 + fi + done # Earlier releases were tagged v3.2.xBeta, so match those too. PREVIOUS_TAG=$(gh release list --repo "$GITHUB_REPOSITORY" --limit 200 --json tagName,createdAt \ --jq '[.[] | select(.tagName | test("^(AndroidAPI_)?v[0-9]"))] | sort_by(.createdAt) | last | .tagName // ""') From f340b347c1504ad30d80ffb61097a23b61bc6eb1 Mon Sep 17 00:00:00 2001 From: JongChern Date: Thu, 15 Oct 2026 12:12:56 +0800 Subject: [PATCH 03/10] DEV-1115 Let a dry run continue past an already-released version The version in the build files is normally one that has already been released until the next uprev, so stopping there made every PR dry run end before the build it is meant to test. Dry runs now warn; a real release still refuses. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 33159659..99a10272 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,6 +89,10 @@ jobs: legacy=${VERSION/_beta/Beta} for t in "$TAG" "AndroidAPI_v$legacy" "v$legacy"; do if git rev-parse -q --verify "refs/tags/$t" >/dev/null; then + if [ "$DRY_RUN" = true ]; then + echo "::warning::$VERSION is already released as $t, so a real release would stop here. Dry run continues." + break + fi echo "::error::$VERSION is already released as $t. Bump the version with an uprev PR first." exit 1 fi From 7a396196416381426a193c77b0b3a4bd132747e4 Mon Sep 17 00:00:00 2001 From: JongChern Date: Thu, 15 Oct 2026 12:15:00 +0800 Subject: [PATCH 04/10] DEV-1115 Make the Gradle wrapper executable gradlew was committed as 100644, so ./gradlew fails with Permission denied on Linux runners (and on any Linux or macOS checkout). Found by this PR's own dry run. Co-Authored-By: Claude Opus 5.5 --- ShimmerAndroidInstrumentDriver/gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 ShimmerAndroidInstrumentDriver/gradlew diff --git a/ShimmerAndroidInstrumentDriver/gradlew b/ShimmerAndroidInstrumentDriver/gradlew old mode 100644 new mode 100755 From 6da0ad475fb9a8bc584fdf55ea2efb8a6cda0553 Mon Sep 17 00:00:00 2001 From: JongChern Date: Fri, 16 Oct 2026 10:45:41 +0800 Subject: [PATCH 05/10] DEV-1115 Pick the version and the driver in the Run form Release Android API now takes both from the Run form instead of from committed build files: - version: blank = next patch after the last release, reading the older 3.2.9Beta tag spelling as 3.2.9_beta (-> 3.2.10_beta) - driver_version: the Shimmer-Java-Android-API release to build against; blank = the newest API_v release. It must have an API_v release. PR dry runs use master's default. The library's publishing version reads -PreleaseVersion ('local' otherwise), and the shimmerdriver/shimmerbluetoothmanager pins read -PdriverVersion, defaulting to master's 0.11.7_beta. The .aar's POM lists no dependencies, so each release's notes now start with the driver version it was built against; that line and the tag rebuild the same .aar. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 131 +++++++++++++----- .../build.gradle | 8 +- ShimmerAndroidInstrumentDriver/build.gradle | 9 +- 3 files changed, 104 insertions(+), 44 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99a10272..b77504a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,47 @@ # One-click release of the Android API: GitHub Packages + a GitHub Release. # # How to release -# 1. Release the Java API first if the driver changed (its "Release Java API" workflow), then -# merge an uprev PR here that bumps the shimmerdriver/shimmerbluetoothmanager pins in -# ShimmerAndroidInstrumentDriver/build.gradle and the publishing `version` in -# ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle. -# master is protected, so this workflow cannot commit the bump itself. -# 2. Actions -> "Release Android API" -> Run workflow (on master). +# Actions -> "Release Android API" -> Run workflow (on master). Both boxes can stay blank: +# - version blank = next patch after the last Android release +# (AndroidAPI_v3.2.9Beta -> 3.2.10_beta), or type one +# - driver_version the Shimmer-Java-Android-API release (shimmerdriver and +# shimmerbluetoothmanager) to build against. Blank = the newest API_v release +# +# Neither version is committed, so master's protection does not get in the way. The library's +# build files read -PreleaseVersion and -PdriverVersion, which this workflow passes. Without them a +# local build is versioned 'local' and uses the default driver in ShimmerAndroidInstrumentDriver/ +# build.gradle. The AndroidAPI_v tag plus the driver version named in its release notes rebuild the +# same .aar. # # One run does, in order, and creates nothing public until the library has built: -# build reads the version from the library's publishing block; fails if that version is -# already tagged (in this or the older v3.2.xBeta form); warns if the driver pins are not the newest Java API release -# (DEV-1115); builds the release .aar; publishes it to GitHub Packages +# build picks both versions; fails if this version is already tagged (in this or the older +# v3.2.xBeta form) or the driver version has no API_v release; builds the release .aar +# against that driver; publishes it to GitHub Packages # release tags AndroidAPI_v on the commit it built and creates the GitHub Release, with -# notes from the previous Android API release and the .aar attached +# the driver version, notes since the previous Android API release, and the .aar # # If only the release job fails, "Re-run failed jobs" re-runs just that job. # -# Reading the driver from Shimmer-Java-Android-API's GitHub Packages uses this repo's GITHUB_TOKEN. -# If that is refused (401/403 resolving com.shimmerresearch:shimmerdriver), add a classic token +# The driver is read from Shimmer-Java-Android-API's GitHub Packages with this repo's GITHUB_TOKEN. +# If that is ever refused (401/403 resolving com.shimmerresearch:shimmerdriver), add a classic token # with read:packages as the PACKAGES_READ_TOKEN secret and it is used instead. # # dry_run builds without publishing, from any branch. The workflow also dry-runs on any PR that -# changes this file. +# changes this file, building against master's default driver. name: Release Android API on: workflow_dispatch: inputs: + version: + description: 'Version, e.g. 3.3.0_beta. Blank = next patch after the last release' + type: string + required: false + driver_version: + description: 'Java API (driver) version to build against, e.g. 0.11.9_beta. Blank = newest release' + type: string + required: false dry_run: description: 'Build only; publish nothing' type: boolean @@ -60,6 +73,7 @@ jobs: version: ${{ steps.version.outputs.version }} tag: ${{ steps.version.outputs.tag }} previous_tag: ${{ steps.version.outputs.previous_tag }} + driver: ${{ steps.version.outputs.driver }} steps: - name: Release from master only if: env.DRY_RUN != 'true' && github.ref != 'refs/heads/master' @@ -72,20 +86,34 @@ jobs: with: fetch-depth: 0 # tags, to refuse a version that is already released - - name: Read the version and check the driver pins + - name: Choose the version and the driver id: version env: GH_TOKEN: ${{ github.token }} + REQUESTED_VERSION: ${{ inputs.version }} + REQUESTED_DRIVER: ${{ inputs.driver_version }} run: | - lib=ShimmerAndroidInstrumentDriver/build.gradle - VERSION=$(sed -nE "s/^[[:space:]]*version = '([^']+)'.*/\1/p" "$lib") - if [ "$(printf '%s\n' "$VERSION" | grep -c .)" -ne 1 ]; then - echo "::error file=ShimmerAndroidInstrumentDriver/$lib::Expected exactly one publishing version = '...' line" + # Earlier releases were tagged v3.2.xBeta, so match those too. + PREVIOUS_TAG=$(gh release list --repo "$GITHUB_REPOSITORY" --limit 200 --json tagName,createdAt \ + --jq '[.[] | select(.tagName | test("^(AndroidAPI_)?v[0-9]"))] | sort_by(.createdAt) | last | .tagName // ""') + if [ -n "$REQUESTED_VERSION" ]; then + VERSION=$REQUESTED_VERSION + else + # Next patch after the last release, keeping its suffix. The older 3.2.9Beta spelling + # counts as 3.2.9_beta, so AndroidAPI_v3.2.9Beta -> 3.2.10_beta. + last=${PREVIOUS_TAG#AndroidAPI_v}; last=${last#v}; last=${last/%Beta/_beta} + if ! [[ "$last" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$ ]]; then + echo "::error::Cannot work out the next version from '${PREVIOUS_TAG:-no previous release}'. Type one in the version box." + exit 1 + fi + VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.$((BASH_REMATCH[3] + 1))${BASH_REMATCH[4]}" + fi + if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+[A-Za-z0-9_.-]*$ ]]; then + echo "::error::'$VERSION' is not a version like 3.2.10_beta." exit 1 fi TAG="AndroidAPI_v$VERSION" - # Releases before this workflow were tagged v3.2.8Beta / AndroidAPI_v3.2.9Beta for version - # 3.2.x_beta, so check those spellings too, or an un-bumped version would be released twice. + # Check the older spellings too, or a version could be released twice under two tags. legacy=${VERSION/_beta/Beta} for t in "$TAG" "AndroidAPI_v$legacy" "v$legacy"; do if git rev-parse -q --verify "refs/tags/$t" >/dev/null; then @@ -93,34 +121,41 @@ jobs: echo "::warning::$VERSION is already released as $t, so a real release would stop here. Dry run continues." break fi - echo "::error::$VERSION is already released as $t. Bump the version with an uprev PR first." + echo "::error::$VERSION is already released as $t. Leave the version blank for the next one, or type another." exit 1 fi done - # Earlier releases were tagged v3.2.xBeta, so match those too. - PREVIOUS_TAG=$(gh release list --repo "$GITHUB_REPOSITORY" --limit 200 --json tagName,createdAt \ - --jq '[.[] | select(.tagName | test("^(AndroidAPI_)?v[0-9]"))] | sort_by(.createdAt) | last | .tagName // ""') + # Driver: typed, else the newest Java API release. A PR dry run uses master's default. + default_driver=$(sed -nE "s/.*findProperty\('driverVersion'\) \?: '([^']+)'.*/\1/p" build.gradle) newest=$(gh release list --repo "$GITHUB_REPOSITORY_OWNER/Shimmer-Java-Android-API" --limit 200 --json tagName,createdAt \ --jq '[.[] | select(.tagName | startswith("API_v"))] | sort_by(.createdAt) | last | .tagName // "" | ltrimstr("API_v")') - pins=$(sed -nE "s/.*name: *'(shimmerdriver|shimmerbluetoothmanager)', *version: *'([^']+)'.*/\1 \2/p" build.gradle) - echo "Driver pins:"; echo "${pins:-}" - echo "Newest Java API release: ${newest:-}" - if [ "$(printf '%s\n' "$pins" | grep -c .)" -ne 2 ]; then - echo "::warning file=ShimmerAndroidInstrumentDriver/build.gradle::Could not read both driver pins, so they were not checked against the newest Java API release." + if [ -n "$REQUESTED_DRIVER" ]; then + DRIVER=$REQUESTED_DRIVER + elif [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then + DRIVER=$newest + else + DRIVER=$default_driver + fi + if [ -z "$DRIVER" ]; then + echo "::error::No driver version: none typed, and none found. Type one in the driver_version box." + exit 1 + fi + if ! gh release view "API_v$DRIVER" --repo "$GITHUB_REPOSITORY_OWNER/Shimmer-Java-Android-API" >/dev/null 2>&1; then + echo "::error::Shimmer-Java-Android-API has no release API_v$DRIVER. Pick a released driver version." + exit 1 + fi + if [ -n "$newest" ] && [ "$DRIVER" != "$newest" ]; then + echo "::warning::Building against driver $DRIVER, but the newest Java API release is $newest." fi - while read -r name pinned; do - if [ -n "$name" ] && [ -n "$newest" ] && [ "$pinned" != "$newest" ]; then - echo "::warning file=ShimmerAndroidInstrumentDriver/build.gradle::$name is pinned at $pinned, but the newest Java API release is $newest. Driver fixes since then are not in this release." - fi - done <<< "$pins" { echo "version=$VERSION" echo "tag=$TAG" echo "previous_tag=$PREVIOUS_TAG" + echo "driver=$DRIVER" } >> "$GITHUB_OUTPUT" - echo "Releasing $VERSION as $TAG (notes since ${PREVIOUS_TAG:-the first commit})" + echo "Releasing $VERSION as $TAG against driver $DRIVER (master's default: ${default_driver:-none}; notes since ${PREVIOUS_TAG:-the first commit})" # AGP 8 needs JDK 17. - name: Set up JDK 17 @@ -135,13 +170,22 @@ jobs: # gradle.properties is gitignored here, so android.useAndroidX (needed for the androidx # dependencies) is passed on the command line. - name: Build the release .aar - run: ./gradlew :ShimmerAndroidInstrumentDriver:assembleRelease -Pandroid.useAndroidX=true + env: + VERSION: ${{ steps.version.outputs.version }} + DRIVER: ${{ steps.version.outputs.driver }} + run: | + ./gradlew :ShimmerAndroidInstrumentDriver:assembleRelease -Pandroid.useAndroidX=true \ + -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" - name: Publish to GitHub Packages if: env.DRY_RUN != 'true' env: GITHUB_TOKEN: ${{ github.token }} - run: ./gradlew :ShimmerAndroidInstrumentDriver:publish -Pandroid.useAndroidX=true + VERSION: ${{ steps.version.outputs.version }} + DRIVER: ${{ steps.version.outputs.driver }} + run: | + ./gradlew :ShimmerAndroidInstrumentDriver:publish -Pandroid.useAndroidX=true \ + -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" - name: Collect the release .aar env: @@ -169,22 +213,33 @@ jobs: VERSION: ${{ needs.build.outputs.version }} TAG: ${{ needs.build.outputs.tag }} PREVIOUS_TAG: ${{ needs.build.outputs.previous_tag }} + DRIVER: ${{ needs.build.outputs.driver }} steps: - uses: actions/download-artifact@v4 with: name: release-assets path: release-assets + # The .aar's POM lists no dependencies, so the notes say which driver to pair it with. - name: Create the tag and GitHub Release working-directory: . run: | + args=(-f tag_name="$TAG" -f target_commitish="$GITHUB_SHA") + if [ -n "$PREVIOUS_TAG" ]; then args+=(-f previous_tag_name="$PREVIOUS_TAG"); fi + driver_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY_OWNER/Shimmer-Java-Android-API/releases/tag/API_v$DRIVER" + { + echo "Built against \`com.shimmerresearch:shimmerdriver\` and \`com.shimmerresearch:shimmerbluetoothmanager\` **$DRIVER** ([API_v$DRIVER]($driver_url)). Add both, at that version, to your app's dependencies." + echo + gh api "repos/$GITHUB_REPOSITORY/releases/generate-notes" "${args[@]}" --jq .body + } > notes.md gh release create "$TAG" release-assets/* \ --repo "$GITHUB_REPOSITORY" \ --target "$GITHUB_SHA" \ --title "$TAG" \ - --generate-notes ${PREVIOUS_TAG:+--notes-start-tag "$PREVIOUS_TAG"} + --notes-file notes.md { echo "### Released Android API $VERSION" echo "- Release: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG" echo "- Package: com.shimmerresearch:shimmerandroidinstrumentdriver:$VERSION" + echo "- Built against driver $DRIVER" } >> "$GITHUB_STEP_SUMMARY" diff --git a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle index 32e270eb..eb8f8dbd 100644 --- a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle @@ -77,15 +77,15 @@ publishing { def getArtificatId = { -> return "ShimmerAndroidInstrumentDriver" // Replace with library name ID } -// Published by the "Release Android API" workflow (.github/workflows/release.yml), which also reads -// the version below: bump it in the uprev PR, then run the workflow. Run assembleRelease before -// publish, because the artifact is the built .aar file. +// Published by the "Release Android API" workflow (.github/workflows/release.yml), which picks the +// version and passes it as -PreleaseVersion; the AndroidAPI_v tags record what was released. Run +// assembleRelease before publish, because the artifact is the built .aar file. publishing { publications { bar(MavenPublication) { groupId = 'com.shimmerresearch' // Replace with your package's group/organization name artifactId = 'shimmerandroidinstrumentdriver' // Replace with the name of your package - version = '3.2.9_beta' // Replace with your package version + version = project.findProperty('releaseVersion') ?: 'local' // set by the Release Android API workflow artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar") } } diff --git a/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/build.gradle index e1e27086..6592508a 100644 --- a/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/build.gradle @@ -23,6 +23,11 @@ apply plugin: 'com.jfrog.artifactory' */ apply plugin: 'maven-publish' +// The shimmerdriver / shimmerbluetoothmanager version (Shimmer-Java-Android-API) that the library and +// every example build against. The default is what master builds with; the Release Android API +// workflow passes -PdriverVersion, by default the newest Java API release. +def shimmerDriverVersion = findProperty('driverVersion') ?: '0.11.7_beta' + allprojects { repositories { google() @@ -78,7 +83,7 @@ allprojects { implementation 'java3d:vecmath:1.3.1' implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.github.Jasonchenlijian:FastBle:2.4.0' - implementation (group: 'com.shimmerresearch', name: 'shimmerbluetoothmanager', version:'0.11.7_beta'){ + implementation (group: 'com.shimmerresearch', name: 'shimmerbluetoothmanager', version: shimmerDriverVersion){ // excluding org.json which is provided by Android exclude group: 'io.netty' @@ -86,7 +91,7 @@ allprojects { exclude group: 'org.apache.commons.math' } - implementation (group: 'com.shimmerresearch', name: 'shimmerdriver', version:'0.11.7_beta'){ + implementation (group: 'com.shimmerresearch', name: 'shimmerdriver', version: shimmerDriverVersion){ // excluding org.json which is provided by Android exclude group: 'io.netty' From 59a50a6498061c40269dc185b1a83ca5b44cddd7 Mon Sep 17 00:00:00 2001 From: Mas Azalya Date: Fri, 16 Oct 2026 12:14:53 +0800 Subject: [PATCH 06/10] DEV-1115 Refuse a 'local' publish and time out a hung build Re-enabling the publishing block means a hand-run `gradlew publish` without -PreleaseVersion would push version 'local' to GitHub Packages, where it can never be overwritten; developers already keep gpr.key in GRADLE_USER_HOME for reading the driver. Publishing to a remote repository now refuses 'local'; publishToMavenLocal is unaffected. Add job timeouts so a hung Gradle daemon cannot hold a runner for the default 6 hours (as happened to the CI run on #124). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 2 ++ .../ShimmerAndroidInstrumentDriver/build.gradle | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b77504a2..372781b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,7 @@ defaults: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 30 # a hung Gradle daemon otherwise holds the runner for 6 hours permissions: contents: read packages: write @@ -206,6 +207,7 @@ jobs: needs: build if: github.event_name == 'workflow_dispatch' && !inputs.dry_run runs-on: ubuntu-latest + timeout-minutes: 10 permissions: contents: write # create the tag and the release env: diff --git a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle index eb8f8dbd..5aa01b7e 100644 --- a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle @@ -104,6 +104,16 @@ publishing { } } } +// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be +// overwritten. Releases go through the Release Android API workflow; publishToMavenLocal is unaffected. +tasks.withType(PublishToMavenRepository).configureEach { + doFirst { + if (publication.version == 'local') { + throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " + + "Release with the Release Android API workflow, or pass -PreleaseVersion.") + } + } +} dependencies { implementation 'com.google.guava:guava:20.0' implementation 'java3d:vecmath:1.3.1' From 2b40f35ba60de1ad7430e36dc34d98a8ffac1096 Mon Sep 17 00:00:00 2001 From: JongChern Date: Sun, 18 Oct 2026 14:16:04 +0800 Subject: [PATCH 07/10] DEV-1115 Publish from a dispatch-only job; build job read-only Same hardening as Shimmer-Java-Android-API#324: - The build job ran on PRs with packages:write. Any code in a job can recover that job's token, so it now has packages:read only (enough to resolve the driver), and a new publish job, which runs only on a real release, is the one place with packages:write. It builds and publishes the .aar and uploads the file it published, so the GitHub Release carries the same .aar as GitHub Packages. The release job waits for it. - Both checkouts set persist-credentials: false, so the token is not left in .git/config for the Gradle build to read. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 59 +++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 372781b4..299e9b3c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,9 @@ # One run does, in order, and creates nothing public until the library has built: # build picks both versions; fails if this version is already tagged (in this or the older # v3.2.xBeta form) or the driver version has no API_v release; builds the release .aar -# against that driver; publishes it to GitHub Packages +# against that driver. Read-only (it reads the driver package): it runs on PRs too. +# publish real releases only, and the only job with packages:write. Builds the .aar the same way, +# publishes it to GitHub Packages, and keeps the .aar it published for the release # release tags AndroidAPI_v on the commit it built and creates the GitHub Release, with # the driver version, notes since the previous Android API release, and the .aar # @@ -62,9 +64,12 @@ jobs: build: runs-on: ubuntu-latest timeout-minutes: 30 # a hung Gradle daemon otherwise holds the runner for 6 hours + # Read-only on purpose: this job also runs on PRs, and any code in a job can recover that + # job's token. packages:read is for resolving the driver; only the publish job, which runs + # on real releases alone, can write packages. permissions: contents: read - packages: write + packages: read env: DRY_RUN: ${{ github.event_name != 'workflow_dispatch' || inputs.dry_run }} # Read by the repositories in the root build.gradle to resolve the driver. @@ -86,6 +91,9 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # tags, to refuse a version that is already released + # Keep the token out of .git/config, where the Gradle build (and any plugin or dependency + # it runs) could read it. Nothing here needs git credentials after checkout; gh uses GH_TOKEN. + persist-credentials: false - name: Choose the version and the driver id: version @@ -178,19 +186,52 @@ jobs: ./gradlew :ShimmerAndroidInstrumentDriver:assembleRelease -Pandroid.useAndroidX=true \ -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" + publish: + needs: build + if: github.event_name == 'workflow_dispatch' && !inputs.dry_run + runs-on: ubuntu-latest + timeout-minutes: 30 # a hung Gradle daemon otherwise holds the runner for 6 hours + permissions: + contents: read + packages: write # also covers reading the driver package + env: + VERSION: ${{ needs.build.outputs.version }} + DRIVER: ${{ needs.build.outputs.driver }} + # Read by the repositories in the root build.gradle to resolve the driver. + USERNAME: ${{ github.actor }} + TOKEN: ${{ secrets.PACKAGES_READ_TOKEN || github.token }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false # publish gets its token explicitly, below + + # AGP 8 needs JDK 17. + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 + + # Run assembleRelease first: the publication's artifact is the built .aar file, and publish + # does not build it itself. + - name: Build the release .aar + run: | + ./gradlew :ShimmerAndroidInstrumentDriver:assembleRelease -Pandroid.useAndroidX=true \ + -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" + + # The library's publishing block reads GITHUB_ACTOR and GITHUB_TOKEN. - name: Publish to GitHub Packages - if: env.DRY_RUN != 'true' env: GITHUB_TOKEN: ${{ github.token }} - VERSION: ${{ steps.version.outputs.version }} - DRIVER: ${{ steps.version.outputs.driver }} run: | ./gradlew :ShimmerAndroidInstrumentDriver:publish -Pandroid.useAndroidX=true \ -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" - - name: Collect the release .aar - env: - VERSION: ${{ steps.version.outputs.version }} + # The .aar just published, so the GitHub Release carries the same file as GitHub Packages. + - name: Collect the published .aar run: | mkdir -p ../release-assets cp ShimmerAndroidInstrumentDriver/build/outputs/aar/ShimmerAndroidInstrumentDriver-release.aar \ @@ -204,7 +245,7 @@ jobs: if-no-files-found: error release: - needs: build + needs: [build, publish] if: github.event_name == 'workflow_dispatch' && !inputs.dry_run runs-on: ubuntu-latest timeout-minutes: 10 From 21446737dc6256f0ee3489fda85bd98e54aaaca4 Mon Sep 17 00:00:00 2001 From: JongChern Date: Sun, 18 Oct 2026 14:40:23 +0800 Subject: [PATCH 08/10] DEV-1115 Build the examples against the chosen driver; pin actions Three follow-ups ahead of review: - The release build job now also builds every example app against the driver this release ships with, before anything is published. ci.yml only ever builds them against master's default driver, so a release that picks a newer driver was never built with the examples (raised in #126). Both build steps pass the 4 GB daemon heap from #125. - The publishing block accepts gpr.usr as well as gpr.user, since the root build.gradle reads gpr.usr (also raised in #126). - actions/* steps are pinned to commit SHAs, matching #124: each is the commit its v4 tag points at today. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 32 +++++++++++++------ .../build.gradle | 9 +++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 299e9b3c..4cc22619 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,8 @@ # One run does, in order, and creates nothing public until the library has built: # build picks both versions; fails if this version is already tagged (in this or the older # v3.2.xBeta form) or the driver version has no API_v release; builds the release .aar -# against that driver. Read-only (it reads the driver package): it runs on PRs too. +# and every example app against that driver. Read-only (it reads the driver package): +# it runs on PRs too. # publish real releases only, and the only job with packages:write. Builds the .aar the same way, # publishes it to GitHub Packages, and keeps the .aar it published for the release # release tags AndroidAPI_v on the commit it built and creates the GitHub Release, with @@ -88,7 +89,7 @@ jobs: echo "::error::A release must run on master, not ${GITHUB_REF_NAME}. Tick dry_run to try another branch." exit 1 - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: fetch-depth: 0 # tags, to refuse a version that is already released # Keep the token out of .git/config, where the Gradle build (and any plugin or dependency @@ -168,7 +169,7 @@ jobs: # AGP 8 needs JDK 17. - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 with: java-version: '17' distribution: 'temurin' @@ -177,14 +178,27 @@ jobs: uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 # gradle.properties is gitignored here, so android.useAndroidX (needed for the androidx - # dependencies) is passed on the command line. + # dependencies) and the daemon heap are passed on the command line. The default 512 MB heap + # runs out dexing the examples (see ci.yml); both steps pass the same value so they share + # one daemon. - name: Build the release .aar env: VERSION: ${{ steps.version.outputs.version }} DRIVER: ${{ steps.version.outputs.driver }} run: | ./gradlew :ShimmerAndroidInstrumentDriver:assembleRelease -Pandroid.useAndroidX=true \ - -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" + -PreleaseVersion="$VERSION" -PdriverVersion="$DRIVER" \ + -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" + + # ci.yml builds the examples against master's default driver. A release can pick another, + # so build every example against the one this release ships with, before anything is + # published. --continue reports every failing module, and the step still fails. + - name: Build every example against the chosen driver + env: + DRIVER: ${{ steps.version.outputs.driver }} + run: | + ./gradlew assembleDebug --continue -Pandroid.useAndroidX=true -PdriverVersion="$DRIVER" \ + -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" publish: needs: build @@ -201,13 +215,13 @@ jobs: USERNAME: ${{ github.actor }} TOKEN: ${{ secrets.PACKAGES_READ_TOKEN || github.token }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false # publish gets its token explicitly, below # AGP 8 needs JDK 17. - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 with: java-version: '17' distribution: 'temurin' @@ -238,7 +252,7 @@ jobs: "../release-assets/shimmerandroidinstrumentdriver-$VERSION.aar" ls -l ../release-assets - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: release-assets path: release-assets/ @@ -258,7 +272,7 @@ jobs: PREVIOUS_TAG: ${{ needs.build.outputs.previous_tag }} DRIVER: ${{ needs.build.outputs.driver }} steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: name: release-assets path: release-assets diff --git a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle index 5aa01b7e..7cdde38f 100644 --- a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle @@ -95,10 +95,11 @@ publishing { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/ShimmerResearch/ShimmerAndroidAPI") credentials { - // Locally: gpr.user and gpr.key in GRADLE_USER_HOME/gradle.properties, with a token - // that has write:packages. In the workflow: GITHUB_ACTOR and GITHUB_TOKEN. These are - // kept apart from USERNAME/TOKEN in the root build.gradle, which only need to read. - username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR") + // Locally: gpr.user (or gpr.usr, the name the root build.gradle reads) and gpr.key in + // GRADLE_USER_HOME/gradle.properties, with a token that has write:packages. In the + // workflow: GITHUB_ACTOR and GITHUB_TOKEN. These are kept apart from USERNAME/TOKEN in + // the root build.gradle, which only need to read. + username = project.findProperty("gpr.user") ?: project.findProperty("gpr.usr") ?: System.getenv("GITHUB_ACTOR") password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") } } From 7e2c4789334d83e6e02e36e669b6aee07d0cbaf5 Mon Sep 17 00:00:00 2001 From: Mas Azalya Date: Mon, 19 Oct 2026 10:48:19 +0800 Subject: [PATCH 09/10] DEV-1115 Exclude JNA from the driver on Android shimmerdriver gained net.java.dev.jna:jna and jna-platform 5.18.1 in April (97bd44ab in Shimmer-Java-Android-API) for the desktop USB debug listeners, and 0.11.8_beta onwards carries them. Android had only ever built against 0.11.7_beta, so nothing saw it until now: against 0.11.9_beta every app fails packaging with "2 files found with path 'META-INF/AL2.0'" from the two JNA jars. A release with the driver box blank would stop at "Build every example against the chosen driver". JNA is desktop-only and nothing on Android loads those classes, so exclude it, as io.netty already is. Checked locally (JDK 17): with -PdriverVersion=0.11.9_beta the release .aar and assembleDebug in all 12 modules build; with the default driver (0.11.7_beta) all 12 still build. Co-Authored-By: Claude Opus 5.5 --- ShimmerAndroidInstrumentDriver/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/build.gradle index 6592508a..10abd3f2 100644 --- a/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/build.gradle @@ -88,6 +88,9 @@ allprojects { // excluding org.json which is provided by Android exclude group: 'io.netty' exclude group: 'com.google.protobuf' + // JNA (in the driver since 0.11.8_beta) is for the desktop USB debug listeners only; on + // Android its two jars clash on META-INF/AL2.0 and fail every app's packaging. + exclude group: 'net.java.dev.jna' exclude group: 'org.apache.commons.math' } @@ -96,6 +99,9 @@ allprojects { // excluding org.json which is provided by Android exclude group: 'io.netty' exclude group: 'com.google.protobuf' + // JNA (in the driver since 0.11.8_beta) is for the desktop USB debug listeners only; on + // Android its two jars clash on META-INF/AL2.0 and fail every app's packaging. + exclude group: 'net.java.dev.jna' } } } From 62c30e6a665a208d431857b76342c2f445f17401 Mon Sep 17 00:00:00 2001 From: Mas Azalya Date: Mon, 19 Oct 2026 11:18:36 +0800 Subject: [PATCH 10/10] DEV-1115 Tell AAR consumers to exclude JNA in the release notes Excluding JNA in this repo's build.gradle does not reach apps that consume the published .aar: its POM lists no dependencies, so they add the driver themselves and would hit the same META-INF/AL2.0 clash with driver 0.11.8_beta or later. The generated notes now say to exclude net.java.dev.jna and link the exclusions this library builds with. Raised by the Copilot review on #127. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4cc22619..8d0d42b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -287,6 +287,9 @@ jobs: { echo "Built against \`com.shimmerresearch:shimmerdriver\` and \`com.shimmerresearch:shimmerbluetoothmanager\` **$DRIVER** ([API_v$DRIVER]($driver_url)). Add both, at that version, to your app's dependencies." echo + # The driver's JNA is desktop-only; its two jars clash on META-INF/AL2.0 in an Android app. + echo "Exclude \`net.java.dev.jna\` from both, or the app fails packaging with \"2 files found with path 'META-INF/AL2.0'\". The exclusions this library builds with are in [ShimmerAndroidInstrumentDriver/build.gradle]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/blob/$TAG/ShimmerAndroidInstrumentDriver/build.gradle)." + echo gh api "repos/$GITHUB_REPOSITORY/releases/generate-notes" "${args[@]}" --jq .body } > notes.md gh release create "$TAG" release-assets/* \