Skip to content

Commit

Permalink
ci: publish workflow (#169)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matthewelwell authored Dec 9, 2024
1 parent 288fe83 commit 07a5940
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# References:
# - https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-maven

name: "Publish to Maven Central"

on:
push:
tags:
- "*"

jobs:
publish-to-maven-central:
runs-on: ubuntu-latest
name: Publish to Maven Central

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 21
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- id: install-secret-key
name: Install gpg secret key
run: |
# Install gpg secret key
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
# Verify gpg secret key
gpg --list-secret-keys --keyid-format LONG
- id: publish-to-central
name: Publish to Central Repository
env:
MAVEN_USERNAME: ${{ vars.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: |
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
clean deploy -P release
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@
<build>
<finalName>flagsmith-java-client-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.6.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down

0 comments on commit 07a5940

Please sign in to comment.