11name : Release And Publish
22
33on :
4+ # Automatic trigger from build-main workflow
5+ workflow_run :
6+ workflows : ["Build Main"]
7+ types : [completed]
8+ branches : [main]
9+
10+ # Manual trigger for production releases
411 workflow_dispatch :
12+ inputs :
13+ releaseType :
14+ description : ' Release type'
15+ required : true
16+ default : ' release'
17+ type : choice
18+ options : ['release', 'snapshot']
19+
20+ # Support existing tag-based releases
521 push :
622 tags :
723 - " v*"
1834 release :
1935 runs-on : ubuntu-latest
2036 timeout-minutes : 30
37+ # Only run if build-main succeeded OR manual/tag trigger
38+ if : |
39+ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
40+ (github.event_name == 'workflow_dispatch') ||
41+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
42+
43+ env :
44+ # GitHub Packages credentials required by buildSrc/Conventions.kt
45+ GPR_USER : ${{ vars.GPR_USER }}
46+ GPR_READ_TOKEN : ${{ secrets.GPR_READ_TOKEN }}
47+
48+ # Maven Central credentials for build system (mcUsername/mcPassword properties)
49+ MC_USERNAME : ${{ secrets.MC_USERNAME }}
50+ MC_PASSWORD : ${{ secrets.MC_PASSWORD }}
51+
52+ # JReleaser credentials (single-line values)
53+ JRELEASER_GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
54+ JRELEASER_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2155
2256 steps :
2357 - name : Checkout Repository
@@ -27,18 +61,44 @@ jobs:
2761 fetch-depth : 0
2862 fetch-tags : true
2963
30- - name : Determine version and create release
64+ - name : Determine Release Context
65+ id : release-context
3166 run : |
32- CURRENT_VERSION=$(./gradlew -q currentVersion)
33- echo "Current version: $CURRENT_VERSION"
67+ if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
68+ echo "📸 Automatic snapshot after successful build"
69+ echo "release_type=snapshot" >> $GITHUB_OUTPUT
70+ echo "trigger_source=automatic" >> $GITHUB_OUTPUT
71+ elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
72+ echo "👤 Manual release triggered"
73+ echo "release_type=${{ github.event.inputs.releaseType }}" >> $GITHUB_OUTPUT
74+ echo "trigger_source=manual" >> $GITHUB_OUTPUT
75+ elif [[ "${{ github.event_name }}" == "push" ]]; then
76+ echo "🏷️ Tag push triggered"
77+ echo "release_type=release" >> $GITHUB_OUTPUT
78+ echo "trigger_source=tag" >> $GITHUB_OUTPUT
79+ fi
3480
35- if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
36- echo "📋 Manual trigger - creating new release"
37- ./gradlew markNextVersion
81+ - name : Generate Version
82+ id : version
83+ run : |
84+ RELEASE_TYPE="${{ steps.release-context.outputs.release_type }}"
85+
86+ if [[ "$RELEASE_TYPE" == "snapshot" ]]; then
87+ echo "🔄 Creating snapshot version"
88+ # Use snapshot mode
89+ VERSION=$(./gradlew -q currentVersion -Prelease.mode=snapshot)
90+ echo "version=$VERSION" >> $GITHUB_OUTPUT
91+ echo "is_snapshot=true" >> $GITHUB_OUTPUT
3892 else
39- echo "🏷️ Tag trigger - version already determined by tag"
93+ echo "🚀 Creating release version"
94+ # Use release mode
95+ VERSION=$(./gradlew -q currentVersion -Prelease.mode=release)
96+ echo "version=$VERSION" >> $GITHUB_OUTPUT
97+ echo "is_snapshot=false" >> $GITHUB_OUTPUT
4098 fi
4199
100+ echo "Final version: $VERSION"
101+
42102 - name : Setup Java
43103 uses : actions/setup-java@v4
44104 with :
@@ -58,6 +118,12 @@ jobs:
58118
59119 # Build & stage all subprojects into root/build/staging-deploy
60120 - name : Build & publish to local staging dir
121+ run : |
122+ ./gradlew --no-daemon build publishAllPublicationsToLocalStagingRepository -Prelease.mode=${{ steps.release-context.outputs.release_type }}
123+
124+ # Export multiline GPG keys (single-line vars are set at job level)
125+ - name : Export GPG keys
126+ shell : bash
61127 run : |
62128 ./gradlew --no-daemon build publishAllPublicationsToLocalStagingRepository
63129
@@ -72,27 +138,21 @@ jobs:
72138 # GPG passphrase
73139 echo "JRELEASER_GPG_PASSPHRASE=${{ secrets.GPG_PASSPHRASE }}" >> $GITHUB_ENV
74140
75- # Armored public key (preserve newlines)
76- echo "JRELEASER_GPG_PUBLIC_KEY<<EOF" >> $GITHUB_ENV
77- echo "${{ secrets.GPG_PUBLIC_KEY }}" >> $GITHUB_ENV
78- echo "EOF" >> $GITHUB_ENV
79-
80- # Armored secret key (preserve newlines)
81- echo "JRELEASER_GPG_SECRET_KEY<<EOF" >> $GITHUB_ENV
82- echo "${{ secrets.GPG_SECRET_KEY }}" >> $GITHUB_ENV
83- echo "EOF" >> $GITHUB_ENV
84-
85- # Use the built-in GitHub token for GitHub release
86- echo "JRELEASER_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
87141
88142 # sanity checks before the real release
89143 - name : JReleaser dry run checks
90- run : ./gradlew --no-daemon jreleaserConfig jreleaserAssemble jreleaserChangelog
144+ run : ./gradlew --no-daemon jreleaserConfig jreleaserAssemble jreleaserChangelog -Prelease.mode=${{ steps.release-context.outputs.release_type }}
91145
92146 # Deploy to Maven Central (Publisher API) and create GitHub Release
93- # Use `jreleaserDeploy` if you ONLY want Central without creating a GH release.
94- - name : JReleaser full release
95- run : ./gradlew --no-daemon jreleaserFullRelease
147+ - name : JReleaser Configuration
148+ run : |
149+ if [[ "${{ steps.version.outputs.is_snapshot }}" == "true" ]]; then
150+ echo "📦 Publishing snapshot to Maven Central staging"
151+ ./gradlew --no-daemon jreleaserDeploy -Prelease.mode=snapshot
152+ else
153+ echo "🎉 Full release to Maven Central and GitHub"
154+ ./gradlew --no-daemon jreleaserFullRelease -Prelease.mode=release
155+ fi
96156
97157 # (Optional) Upload JReleaser output for debugging/audit
98158 - name : Upload JReleaser output
0 commit comments