Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
publish-android:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write
steps:
- uses: actions/checkout@v4
Expand All @@ -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
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[@]}"
6 changes: 6 additions & 0 deletions scripts/publish-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading