11name : Release (manual)
22on :
3- workflow_dispatch : {}
3+ workflow_dispatch :
4+ inputs :
5+ version :
6+ description : ' Version to release (e.g. 1.2.3). Leave empty to use build.gradle'
7+ required : false
8+ type : string
49
510env :
611 SIGNING_KEY_FILE_PATH : /home/runner/secretKey.gpg
@@ -27,10 +32,14 @@ jobs:
2732 needs : [lint, test, build]
2833 runs-on : ubuntu-latest
2934 permissions :
30- contents : read
35+ contents : write
3136 steps :
3237 - name : Checkout Repository
3338 uses : actions/checkout@v4
39+ with :
40+ fetch-depth : ' 0'
41+ persist-credentials : true
42+ token : ${{ secrets.GITHUB_TOKEN }}
3443
3544 - name : Set up JDK 17
3645 uses : actions/setup-java@v4
4453 signing_key_file : ${{ secrets.SIGNING_KEY_FILE }}
4554 signing_file_path : ${{ env.SIGNING_KEY_FILE_PATH }}
4655
56+ - name : Optionally set version in Gradle
57+ if : ${{ inputs.version != '' }}
58+ run : ./gradlew -PversionParam="${{ inputs.version }}" changeReleaseVersion
59+
60+ - name : Determine version
61+ run : |
62+ if [ -n "${{ inputs.version }}" ]; then
63+ echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
64+ else
65+ VERSION=$(grep -o '"sdkVersionName"\s*:\s*"[^"]*"' build.gradle | grep -o '"[^\"]*"$' | tr -d '"')
66+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
67+ fi
68+
4769 - name : Set snapshot environment variable
4870 run : echo "USE_SNAPSHOT=false" >> $GITHUB_ENV
4971
6183 echo "Running direct deployment script..."
6284 bash -e ./deploy-to-maven-central.sh --no-auto-publish
6385
86+ - name : Configure Git user
87+ run : |
88+ git config user.name "github-actions[bot]"
89+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
90+
91+ - name : Create and push tag
92+ run : |
93+ git fetch --tags --force
94+ if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
95+ echo "Tag v${VERSION} already exists; skipping tag creation"
96+ else
97+ git tag "v${VERSION}"
98+ git push origin "v${VERSION}"
99+ fi
100+
101+ - name : Create GitHub Release
102+ uses : softprops/action-gh-release@v2
103+ with :
104+ tag_name : " v${{ env.VERSION }}"
105+ name : " v${{ env.VERSION }}"
106+ generate_release_notes : true
107+ env :
108+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
109+
64110 - name : Cleanup signing key files
65111 if : always()
112+ shell : bash
66113 run : |
67114 shred -u -z -n 3 "${SIGNING_KEY_FILE_PATH}" || rm -f "${SIGNING_KEY_FILE_PATH}"
68- rm -f ~/secretKey.gpg.b64 || true
69- shell : bash
115+ rm -f ~/secretKey.gpg.b64 || true
0 commit comments