diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml index 708fa17..aefa093 100644 --- a/.github/workflows/publish-android.yml +++ b/.github/workflows/publish-android.yml @@ -6,7 +6,7 @@ jobs: publish-android: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write steps: - uses: actions/checkout@v4 @@ -31,5 +31,35 @@ jobs: EOF echo "local.properties file has been created successfully." - name: Run publish script + id: publish working-directory: ./scripts - run: ./publish-android.sh \ No newline at end of file + run: ./publish-android.sh + - name: Create GitHub release + # Only when this run actually published a new version, and only from a release branch + if: steps.publish.outputs.published == 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next') + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ steps.publish.outputs.version }} + run: | + if gh release view "$VERSION" > /dev/null 2>&1; then + echo "Release $VERSION already exists, skipping." + exit 0 + fi + + # Release notes: the matching CHANGELOG.md section, falling back to generated notes + awk -v v="$VERSION" ' + /^## / { if (found) exit; h=$0; sub(/^## \[?v?/, "", h); sub(/\].*$/, "", h); sub(/ .*$/, "", h); if (h == v) { found=1; next } } + found { print } + ' CHANGELOG.md > release-notes.md 2>/dev/null || true + + args=(--target "$GITHUB_SHA" --title "$VERSION") + if [[ -s release-notes.md ]] && grep -q '[^[:space:]]' release-notes.md; then + args+=(--notes-file release-notes.md) + else + args+=(--generate-notes) + fi + if [[ "$VERSION" == *-* ]]; then + args+=(--prerelease) + fi + + gh release create "$VERSION" "${args[@]}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9585e..e29c79c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,33 +6,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 The changes documented here do not include those from the original repository. -# [Unreleased] +## [Unreleased] -# [2.1.2] +## [2.1.2] ### 2026-10-30 - Chore: Update dependencies and build tooling (Gradle 8.14.3, AGP 8.13.0, Kotlin 1.9.25, compileSdk/targetSdk 36, androidx libraries, CameraX 1.4.2, zxing, gson). -# [2.1.1] +## [2.1.1] ### 2026-08-03 - Show camera preview only after permission is granted. This issue was uncovered while updating a consumer app's androidx camera2 dependency do 1.6.2 (https://outsystemsrd.atlassian.net/browse/RMET-5329 + https://github.com/OutSystems/OSBarcodeLib-Android/issues/57) -# [2.1.0] +## [2.1.0] ### 2026-06-26 - Add optional `cancelButtonAccessibilityLabel`, `torchButtonOnAccessibilityLabel` and `torchButtonOffAccessibilityLabel` scan parameters to set the alternative text (content description) read by screen readers on the Cancel and Torch buttons. When not provided, no label is set, keeping the previous behavior unchanged. (https://github.com/OutSystems/OSBarcodeLib-Android/issues/54) -# [2.0.2] +## [2.0.2] ### 2026-06-25 - Prevent Expanded Dark Theme inversion on scanner activity (https://outsystemsrd.atlassian.net/browse/RMET-5280) -# [2.0.1] +## [2.0.1] ### 2025-10-02 diff --git a/scripts/publish-android.sh b/scripts/publish-android.sh index a8b422e..8e567b3 100755 --- a/scripts/publish-android.sh +++ b/scripts/publish-android.sh @@ -29,6 +29,12 @@ else if grep --quiet "BUILD SUCCESSFUL" $LOG_OUTPUT; then printf %"s\n" "Success: Published to MavenCentral." + + # Let the workflow know a new version was published (used to create the GitHub release) + if [[ -n "$GITHUB_OUTPUT" ]]; then + echo "published=true" >> "$GITHUB_OUTPUT" + echo "version=$THE_VERSION" >> "$GITHUB_OUTPUT" + fi else printf %"s\n" "Error publishing, check $LOG_OUTPUT for more info! Manually review and release from the Central Portal may be necessary https://central.sonatype.com/publishing/deployments/" cat $LOG_OUTPUT