diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml index 117f9c6fe5..55dff90da5 100644 --- a/.github/workflows/publish-android.yml +++ b/.github/workflows/publish-android.yml @@ -12,6 +12,11 @@ on: version: description: "Version/tag to publish (e.g., v0.7.0-rc.50 or 0.7.0-rc.50)" required: true + dry_run: + description: "Build and upload CI artifacts without publishing" + type: boolean + required: false + default: false jobs: publish: @@ -24,14 +29,21 @@ jobs: - name: Normalize release version id: version shell: bash + env: + INPUT_VERSION: ${{ inputs.version || github.event.release.tag_name || github.ref_name }} run: | - VERSION="${{ github.event.inputs.version || github.event.release.tag_name || github.ref_name }}" - TAG="$VERSION" + if [[ ! "$INPUT_VERSION" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then + echo "Invalid release version/tag" >&2 + exit 1 + fi + TAG="$INPUT_VERSION" if [[ "$TAG" != v* ]]; then TAG="v$TAG" fi echo "tag=$TAG" >> "$GITHUB_OUTPUT" echo "version=${TAG#v}" >> "$GITHUB_OUTPUT" + echo "RELEASE_TAG=$TAG" >> "$GITHUB_ENV" + echo "RELEASE_VERSION=${TAG#v}" >> "$GITHUB_ENV" - uses: actions/checkout@v4 with: @@ -52,6 +64,8 @@ jobs: - name: Set up Android SDK uses: android-actions/setup-android@v3 + with: + packages: platform-tools - name: Set up Android NDK id: setup-ndk @@ -73,7 +87,7 @@ jobs: - name: Build with Gradle working-directory: bindings/kotlin/ldk-node-android - run: ./gradlew build -Pversion=${{ steps.version.outputs.version }} + run: ./gradlew build "-Pversion=$RELEASE_VERSION" - name: Upload native debug symbols artifact uses: actions/upload-artifact@v4 @@ -82,14 +96,16 @@ jobs: path: bindings/kotlin/ldk-node-android/native-debug-symbols.zip - name: Upload native debug symbols to release + if: ${{ !inputs.dry_run }} env: GH_TOKEN: ${{ github.token }} - run: gh release upload "${{ steps.version.outputs.tag }}" bindings/kotlin/ldk-node-android/native-debug-symbols.zip --clobber + run: gh release upload "$RELEASE_TAG" bindings/kotlin/ldk-node-android/native-debug-symbols.zip --clobber - name: Publish to GitHub Packages + if: ${{ !inputs.dry_run }} working-directory: bindings/kotlin/ldk-node-android env: GITHUB_ACTOR: ${{ github.actor }} GITHUB_TOKEN: ${{ github.token }} GITHUB_REPO: ${{ github.repository }} - run: ./gradlew publish -Pversion=${{ steps.version.outputs.version }} + run: ./gradlew publish "-Pversion=$RELEASE_VERSION"