From 0a2bc525f19be643f666eddee731ce034a5ec7fc Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 29 Oct 2025 10:46:37 -0400 Subject: [PATCH 1/5] Option to release or just publish --- .github/workflows/publish-release.yml | 59 +++++++++++++++------------ 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ad441806db..ed0e6e4b38 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,30 +1,30 @@ name: Publish Release on: - push: - branches: - - main - - '*-main' # Matches 5.4-main, 5.5-main, etc. workflow_dispatch: inputs: ref: description: "Branch or commit SHA to run on" required: false default: "main" + release_on_maven: + description: "Release on Maven Central" + required: true + default: true + type: boolean permissions: contents: write pull-requests: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: publish: runs-on: ubuntu-latest - # Auto-run only if this is a rel/* merge commit, OR manual dispatch - if: github.event_name == 'workflow_dispatch' || - (startsWith(github.event.head_commit.message, 'Merge pull request') && - contains(github.event.head_commit.message, 'rel/')) - env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} @@ -40,17 +40,6 @@ jobs: with: ref: ${{ github.event.inputs.ref || github.sha }} - - name: Detect current branch - id: detect_branch - run: | - if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then - BRANCH="${{ github.event.inputs.ref }}" - else - BRANCH="${{ github.ref_name }}" - fi - echo "CURRENT_BRANCH=$BRANCH" >> $GITHUB_ENV - echo "Publishing from branch: $BRANCH" - - name: Ensure Java 11 or 17 run: | CURRENT_JAVA=$(java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}') @@ -94,7 +83,16 @@ jobs: -Psigning.password="$SDK_SIGNING_PASSWORD" \ -Psigning.secretKeyRingFile="$GPG_FILE_PATH" - - name: Publish to Maven Central + - name: Determine Publishing Method + run: | + if [[ "${{ github.event.inputs.release_on_maven }}" == "true" ]]; then + echo "✅ Publishing to Maven Central And Release" + else + echo "🏠 Publishing to Maven Central - Not Releasing" + fi + + - name: Publish and Release to Maven Central + if: github.event.inputs.release_on_maven == 'true' working-directory: OneSignalSDK run: | ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache \ @@ -104,19 +102,28 @@ jobs: -Psigning.password="$SDK_SIGNING_PASSWORD" \ -Psigning.secretKeyRingFile="$GPG_FILE_PATH" - - name: Get latest merged rel/* PR + - name: Publish Only to Maven Central + if: github.event.inputs.release_on_maven != 'true' + working-directory: OneSignalSDK + run: | + ./gradlew publishToMavenCentral --no-configuration-cache \ + -PmavenCentralUsername="$MAVEN_USERNAME" \ + -PmavenCentralPassword="$MAVEN_PASSWORD" \ + -Psigning.keyId="$SDK_SIGNING_KEY_ID" \ + -Psigning.password="$SDK_SIGNING_PASSWORD" \ + -Psigning.secretKeyRingFile="$GPG_FILE_PATH" + + - name: Get latest merged rel/* PR into main id: fetch_pr run: | - echo "Looking for merged release PRs into base branch: $CURRENT_BRANCH" - PR_JSON=$(gh pr list \ --state merged \ - --base "$CURRENT_BRANCH" \ + --base main \ --json number,title,body,headRefName,mergedAt \ --jq '[.[] | select(.headRefName | startswith("rel/"))] | sort_by(.mergedAt) | last') if [[ -z "$PR_JSON" || "$PR_JSON" == "null" ]]; then - echo "❌ No merged release PR found for base branch: $CURRENT_BRANCH" + echo "❌ No merged release PR found." exit 1 fi From 067dd8a62370480b746dfe21dcf6798a3e650274 Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 29 Oct 2025 10:53:29 -0400 Subject: [PATCH 2/5] branch --- .github/workflows/publish-release.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ed0e6e4b38..18360be28e 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -40,6 +40,17 @@ jobs: with: ref: ${{ github.event.inputs.ref || github.sha }} + - name: Detect current branch + id: detect_branch + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + BRANCH="${{ github.event.inputs.ref }}" + else + BRANCH="${{ github.ref_name }}" + fi + echo "CURRENT_BRANCH=$BRANCH" >> $GITHUB_ENV + echo "Publishing from branch: $BRANCH" + - name: Ensure Java 11 or 17 run: | CURRENT_JAVA=$(java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}') @@ -118,12 +129,12 @@ jobs: run: | PR_JSON=$(gh pr list \ --state merged \ - --base main \ + --base "$CURRENT_BRANCH" \ --json number,title,body,headRefName,mergedAt \ --jq '[.[] | select(.headRefName | startswith("rel/"))] | sort_by(.mergedAt) | last') if [[ -z "$PR_JSON" || "$PR_JSON" == "null" ]]; then - echo "❌ No merged release PR found." + echo "❌ No merged release PR found for base branch: $CURRENT_BRANCH" exit 1 fi From c7169c969e186debe0aca2bf6d34db3f5fe35263 Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 29 Oct 2025 10:55:15 -0400 Subject: [PATCH 3/5] branch --- .github/workflows/publish-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 18360be28e..8f9ddb17f3 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -43,7 +43,7 @@ jobs: - name: Detect current branch id: detect_branch run: | - if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then BRANCH="${{ github.event.inputs.ref }}" else BRANCH="${{ github.ref_name }}" From c314be6608587ce29f41812165243a3642c11b48 Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 29 Oct 2025 12:23:38 -0400 Subject: [PATCH 4/5] creating a release tag only when its publishRelease on maven --- .github/workflows/publish-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 8f9ddb17f3..a5ffef1b9c 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -145,6 +145,7 @@ jobs: echo "$PR_BODY" > release_notes.md - name: Tag and create GitHub Release + if: github.event.inputs.release_on_maven != 'true' run: | VERSION="${{ env.SDK_VERSION }}" From 9ade003b913b4669359841f7733aaf9151b262ca Mon Sep 17 00:00:00 2001 From: abdulraqeeb33 Date: Wed, 29 Oct 2025 12:39:46 -0400 Subject: [PATCH 5/5] Change condition for GitHub Release tagging --- .github/workflows/publish-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index a5ffef1b9c..6b7bd1894a 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -145,7 +145,7 @@ jobs: echo "$PR_BODY" > release_notes.md - name: Tag and create GitHub Release - if: github.event.inputs.release_on_maven != 'true' + if: github.event.inputs.release_on_maven == 'true' run: | VERSION="${{ env.SDK_VERSION }}" @@ -173,4 +173,4 @@ jobs: gh release create "$VERSION" \ --title "$VERSION" \ --notes-file release_notes.md \ - $PRERELEASE \ No newline at end of file + $PRERELEASE