-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from dm-drogeriemarkt/github-actions
use GitHub actions for CI/CD
- Loading branch information
Showing
14 changed files
with
168 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Secrets needed for deployment | ||
|
||
Secrets are stored in an environment for Github Actions to deploy to the Sonatype OSS repo. | ||
|
||
## GPG_KEYNAME | ||
|
||
The name of the GPG key used for signing. See `gpg -K` for key names. | ||
|
||
## GPG_KEY_BASE64 | ||
|
||
Base64-encoded key export of the signing key. | ||
|
||
```shell | ||
gpg --export-secret-keys ${GPG_KEYNAME} | base64 | ||
``` | ||
|
||
## GPG_PASSPHRASE | ||
|
||
Passphrase of the GPG key | ||
|
||
## OSSRH_JIRA_USERNAME | ||
|
||
User name used for authenticating at the Sonatype OSS repo. Same as the Password used to log in | ||
at https://issues.sonatype.org | ||
|
||
## OSSRH_JIRA_PASSWORD | ||
|
||
Password used for authenticating at the Sonatype OSS repo. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
KEY_FILE='daniel.flassak.open.source.private.key' | ||
|
||
echo $GPG_KEY_BASE64 | base64 -d > ${KEY_FILE} | ||
gpg --passphrase "${GPG_PASSPHRASE}" --batch --yes --fast-import ${KEY_FILE} | ||
|
||
if [[ "${REF_TYPE}" == "tag" ]]; then | ||
# 'install' cannot be used in addition to 'deploy', because that makes the signatures invalid by re-creating jars | ||
# after they have been signed. | ||
# | ||
# So we can **only** call the 'deploy' target here, which is why 'source:jar' and 'javadoc:jar' are called | ||
# explicitly before 'deploy' so that their artifacts are signed, too. | ||
# | ||
# '-P sign' is used here instead of 'gpg:sign', because 'gpg:sign' seemingly has the same effect as 'install' | ||
# (invalid signatures to to re-created jars) | ||
# | ||
# There may be an easier way to sign and deploy all the artifacts (sources, javadoc, binaries and pom), but after | ||
# four hours of debugging this, I'm satisfied that it works at all. | ||
mvn --batch-mode -DskipTests=true -Dproject.version=${REF_NAME} -P sign clean source:jar javadoc:jar deploy | ||
SUCCESS=$? | ||
else | ||
echo "this should only be run for tags" | ||
SUCCESS=1 | ||
fi | ||
|
||
# just to be safe, although this deleting these should not be necessary | ||
rm ${KEY_FILE} | ||
rm -rf ~/.gnupg | ||
|
||
exit ${SUCCESS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Build and deploy to Sonatype OSS repo | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
- '[0-9]+.[0-9]+.[0-9]+-SNAPSHOT' | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/run-with-maven.yml | ||
with: | ||
COMMAND: mvn --batch-mode -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.showWarnings=true clean verify | ||
deploy: | ||
needs: build | ||
uses: ./.github/workflows/run-with-maven.yml | ||
with: | ||
ENVIRONMENT: sonatype-oss | ||
COMMAND: ./.github/sign_and_deploy.sh | ||
secrets: | ||
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }} | ||
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }} | ||
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/run-with-maven.yml | ||
with: | ||
COMMAND: > | ||
mvn --batch-mode -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.showWarnings=true -Dproject.version=0.0.0-SNAPSHOT clean install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Java CI with Maven | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
COMMAND: | ||
description: command to execute in mvn context | ||
type: string | ||
required: true | ||
ENVIRONMENT: | ||
type: string | ||
required: false | ||
secrets: | ||
GPG_KEYNAME: | ||
required: false | ||
GPG_PASSPHRASE: | ||
required: false | ||
GPG_KEY_BASE64: | ||
required: false | ||
OSSRH_JIRA_PASSWORD: | ||
required: false | ||
OSSRH_JIRA_USERNAME: | ||
required: false | ||
|
||
jobs: | ||
run-with-maven: | ||
runs-on: ubuntu-latest | ||
|
||
environment: ${{ inputs.ENVIRONMENT }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Cache local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '8' | ||
distribution: 'adopt' | ||
cache: maven | ||
|
||
- name: Run with mvn context | ||
env: | ||
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }} | ||
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }} | ||
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME}} | ||
COMMAND: ${{ inputs.COMMAND }} | ||
REF_TYPE: ${{ github.ref_type }} | ||
REF_NAME: ${{ github.ref_name }} | ||
|
||
run: | ||
cp .github/mvnsettings.xml ~/.m2/settings.xml && eval "${COMMAND}" |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters