diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..96d3da8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/pom.xml b/pom.xml index 3c2a68c..b84316e 100644 --- a/pom.xml +++ b/pom.xml @@ -181,6 +181,16 @@ flagsmith-java-client-${project.version} + + org.sonatype.central + central-publishing-maven-plugin + 0.6.0 + true + + central + true + + org.apache.maven.plugins maven-compiler-plugin