Skip to content

Commit 255ec36

Browse files
workflow publish for java sdk
1 parent c3893e7 commit 255ec36

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
type: string
8+
description: Tag to publish (e.g. v2.0.16)
9+
required: true
10+
11+
jobs:
12+
validate-tag:
13+
name: Validate tag
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Verify tag exists
22+
run: |
23+
TAG="${{ github.event.inputs.tag }}"
24+
if [ -z "$TAG" ]; then
25+
echo "Error: Tag is required."
26+
exit 1
27+
fi
28+
if ! git rev-parse "$TAG" >/dev/null 2>&1; then
29+
echo "Error: Tag '$TAG' does not exist."
30+
exit 1
31+
fi
32+
echo "Publishing tag: $TAG"
33+
34+
publish:
35+
name: Test, release build and publish
36+
needs: [validate-tag]
37+
if: ${{ !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout tag
41+
uses: actions/checkout@v6
42+
with:
43+
ref: ${{ github.event.inputs.tag }}
44+
45+
- name: Set up Maven Central Repository
46+
uses: actions/setup-java@v5
47+
with:
48+
java-version: 21
49+
distribution: 'temurin'
50+
server-id: central
51+
server-username: MAVEN_USERNAME
52+
server-password: MAVEN_PASSWORD
53+
gpg-private-key: ${{ secrets.SIGNING_KEY }}
54+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
55+
56+
- name: Publish to Maven Central
57+
run: cd zero-bounce-sdk && mvn --no-transfer-progress --batch-mode -Dgpg.passphrase=${MAVEN_GPG_PASSPHRASE} clean deploy -Prelease
58+
env:
59+
MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
60+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
61+
MAVEN_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}

0 commit comments

Comments
 (0)