Skip to content

Commit

Permalink
Add workflow to upload to Maven Central (#229)
Browse files Browse the repository at this point in the history
* Add workflow to upload to Maven Central

* Add JDK 17
  • Loading branch information
sceiler authored Mar 20, 2022
1 parent d07d696 commit 80a58af
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
65 changes: 23 additions & 42 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,34 @@
# This is a basic workflow to help you get started with Actions

name: Release to Maven Central

# Run this manually
on:
workflow_dispatch:
inputs:
releaseType:
description: MAJOR, MINOR or PATCH release
default: 'PATCH'
dry_run:
description: Whether to perform a dry run instead of a full release.
default: false
releaseversion:
description: 'Release version'
required: true
default: '1.1.0'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
release:
name: Preparing Build Environment

# The type of runner that the job will run on
publish:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Set up JDK 1.8
uses: actions/[email protected]
with:
java-version: 1.8
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Install Maven
uses: aahmed-se/setup-maven@v3
with:
maven-version: 3.6.1

- run: echo "Will start a Maven Central upload with version ${{ github.event.inputs.releaseversion }}"
- uses: actions/checkout@v2

- name: Build & Test
run: mvn -B test --file pom.xml

- name: Prepare Release
env:
passphrase: ${{ secrets.GPG_PASSPHRASE }}
run: mvn -B release:clean release:prepare -DRELEASE_TYPE=$INPUT_RELEASETYPE -DdryRun=$INPUT_DRY_RUN

- name: Perform Release
if: ${{ env.INPUT_DRY_RUN == false }}
- name: Set up Maven Central Repository
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Set projects Maven version to GitHub Action GUI set version
run: mvn versions:set "-DnewVersion=${{ github.event.inputs.releaseversion }}"
- name: Publish package
run: mvn -B --no-transfer-progress deploy -DskipTests=true
env:
ossrc-username: ${{ secrets.ossrc_username }}
ossrc-password: ${{ secrets.ossrc_password }}
run: mvn -B release:perform
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down

0 comments on commit 80a58af

Please sign in to comment.