Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Set up Actions-based release process #326

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow will build a Java project with Maven and publish it to Maven Central Repository
# ref: https://github.com/actions/setup-java/blob/v3.11.0/docs/advanced-usage.md#Publishing-using-Apache-Maven

# Secrets required:
# - MAVEN_USERNAME: Username for Maven Central Repository
# - MAVEN_CENTRAL_TOKEN: Token/password for Maven Central Repository
# - MAVEN_GPG_PRIVATE_KEY: GPG private key to sign the artifacts
# - MAVEN_GPG_PASSPHRASE: Passphrase for the GPG private key

name: Publish library to Maven Central Repository

on:
release:
types: [ created ]
secrets:
MAVEN_USERNAME:
required: true
MAVEN_CENTRAL_TOKEN:
required: true
MAVEN_GPG_PRIVATE_KEY:
required: true
MAVEN_GPG_PASSPHRASE:
required: true
workflow_dispatch: ~

jobs:
release:
runs-on: ubuntu-20.04
nwithan8 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install JDK
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "22" # Always use the latest JDK
server-id: "ossrh"
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
nwithan8 marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: make install

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to Apache Maven Central
run: mvn deploy
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
nwithan8 marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload output files to release
uses: AButler/[email protected]
with:
files: "target/*.jar;target/*.pom;target/*.asc"
repo-token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<!-- Needed to read passphrase from settings.xml -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
Loading