Skip to content

Commit 07a5940

Browse files
ci: publish workflow (#169)
* Add central publishing package * Add publish workflow * Add current branch to workflow * fix syntax * Add runs-on and name * Add checkout and setup java * Add skip tests * Remove skipTests and checkout submodules * Play around with more vars to set up java * Bump version * Add profile * Revert changes to pom.xml * Remove branch from publish workflow
1 parent 288fe83 commit 07a5940

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/publish.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# References:
2+
# - https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-maven
3+
4+
name: "Publish to Maven Central"
5+
6+
on:
7+
push:
8+
tags:
9+
- "*"
10+
11+
jobs:
12+
publish-to-maven-central:
13+
runs-on: ubuntu-latest
14+
name: Publish to Maven Central
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
- uses: actions/setup-java@v4
21+
with:
22+
distribution: adopt
23+
java-version: 21
24+
server-id: central
25+
server-username: MAVEN_USERNAME
26+
server-password: MAVEN_PASSWORD
27+
28+
- id: install-secret-key
29+
name: Install gpg secret key
30+
run: |
31+
# Install gpg secret key
32+
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
33+
# Verify gpg secret key
34+
gpg --list-secret-keys --keyid-format LONG
35+
- id: publish-to-central
36+
name: Publish to Central Repository
37+
env:
38+
MAVEN_USERNAME: ${{ vars.OSSRH_USERNAME }}
39+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
40+
run: |
41+
mvn \
42+
--no-transfer-progress \
43+
--batch-mode \
44+
-Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
45+
clean deploy -P release

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@
181181
<build>
182182
<finalName>flagsmith-java-client-${project.version}</finalName>
183183
<plugins>
184+
<plugin>
185+
<groupId>org.sonatype.central</groupId>
186+
<artifactId>central-publishing-maven-plugin</artifactId>
187+
<version>0.6.0</version>
188+
<extensions>true</extensions>
189+
<configuration>
190+
<publishingServerId>central</publishingServerId>
191+
<autoPublish>true</autoPublish>
192+
</configuration>
193+
</plugin>
184194
<plugin>
185195
<groupId>org.apache.maven.plugins</groupId>
186196
<artifactId>maven-compiler-plugin</artifactId>

0 commit comments

Comments
 (0)