Skip to content

Commit f35fef9

Browse files
authored
Deploy in GitHub Actions with semantic versioning (#80)
1 parent 12e470b commit f35fef9

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Publish package to Maven Central
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
types: [closed]
7+
8+
jobs:
9+
publish:
10+
if: github.event.pull_request.merged == true
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Step 1 - Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Step 2 - Import GPG key
17+
run: |
18+
echo "${{ secrets.GPG_PUBLIC_KEY }}" | gpg --import
19+
echo "${{ secrets.GPG_SECRET_KEY }}" | gpg --import --no-tty --batch --yes
20+
21+
- name: Step 3 - Set up Maven Central Repository
22+
uses: actions/setup-java@v3
23+
with:
24+
java-version: "8"
25+
distribution: "adopt"
26+
server-id: ossrh
27+
server-username: ${{ secrets.OSSRH_USERNAME }}
28+
server-password: ${{ secrets.OSSRH_TOKEN }}
29+
30+
- name: Step 4 - Install GitVersion
31+
uses: gittools/actions/gitversion/setup@v0
32+
with:
33+
versionSpec: '5.x'
34+
- name: Step 5 - Determine Version
35+
id: gitversion
36+
uses: gittools/actions/gitversion/execute@v0
37+
with:
38+
useConfigFile: true
39+
40+
- name: Step 6 - Create Release
41+
id: create_release
42+
uses: actions/create-release@latest
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
TITLE: ${{ github.event.pull_request.title }}
46+
BODY: ${{ github.event.pull_request.body }}
47+
VERSION: "v${{ steps.gitversion.outputs.semVer }}"
48+
with:
49+
tag_name: $VERSION
50+
release_name: $VERSION $TITLE
51+
body: $BODY
52+
draft: false
53+
prerelease: false
54+
55+
- name: Step 7 - Publish package
56+
run: |
57+
mvn -P release -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
58+
-Drevision=${{ steps.gitversion.outputs.semVer }} deploy

GitVersion.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mode: Mainline
2+
increment: Inherit
3+
branches: {}
4+
ignore:
5+
sha: []

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@
246246
<goals>
247247
<goal>sign</goal>
248248
</goals>
249+
<configuration>
250+
<gpgArguments>
251+
<arg>--pinentry-mode</arg>
252+
<arg>loopback</arg>
253+
</gpgArguments>
254+
</configuration>
249255
</execution>
250256
</executions>
251257
</plugin>

0 commit comments

Comments
 (0)