Skip to content

Commit 93faff2

Browse files
authored
Release to maven central (#9)
Configure publication to Maven Central * Add Maven wrapper * Add a release workflow * Update existing GH workflows
1 parent 02b226d commit 93faff2

File tree

10 files changed

+885
-27
lines changed

10 files changed

+885
-27
lines changed

.github/workflows/linter.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
name: CDEvents
2+
name: Linter
33
on:
44
pull_request:
5-
branches: [ main ]
5+
branches: [main]
66
jobs:
77
build:
88
name: Lint Code Base
@@ -19,3 +19,5 @@ jobs:
1919
VALIDATE_ALL_CODEBASE: false
2020
DEFAULT_BRANCH: main
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
# mvnw is provided as is from the Maven Wrapper project. Can't change it
23+
FILTER_REGEX_EXCLUDE: .*mvnw

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: Release
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Release version'
9+
required: true
10+
11+
env:
12+
JAVA_VERSION: '11'
13+
JAVA_DISTRO: 'zulu'
14+
USER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
15+
USER_NAME: 'GitHub Action'
16+
17+
jobs:
18+
release:
19+
name: Release
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout sources
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Java
29+
uses: actions/setup-java@v3
30+
with:
31+
java-version: ${{ env.JAVA_VERSION }}
32+
distribution: ${{ env.JAVA_DISTRO }}
33+
server-id: central
34+
server-username: MAVEN_USERNAME
35+
server-password: MAVEN_CENTRAL_TOKEN
36+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
37+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
38+
39+
- name: Cache Maven
40+
uses: actions/cache@v2
41+
with:
42+
path: ~/.m2/repository
43+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
44+
restore-keys: ${{ runner.os }}-m2
45+
46+
- name: Version
47+
run: |
48+
VERSION=${{ github.event.inputs.version }}
49+
echo "Updating POMs to version $VERSION"
50+
./mvnw -B versions:set versions:commit -DnewVersion=$VERSION
51+
git config --global user.email "${{ env.USER_EMAIL }}"
52+
git config --global user.name "${{ env.USER_NAME }}"
53+
git commit -a -m "Releasing version $VERSION"
54+
git push origin main
55+
56+
- name: Release
57+
env:
58+
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
59+
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
60+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
61+
run: |
62+
GPG_TTY=$(tty)
63+
export GPG_TTY
64+
./mvnw --no-transfer-progress -B --file pom.xml \
65+
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \
66+
-Dmaven.site.skip=true -Drelease=true deploy

.github/workflows/test.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
---
2-
name: CDEvents
2+
name: Test
33
on:
44
pull_request:
5-
branches: [ main ]
5+
branches: [main]
6+
7+
env:
8+
JAVA_VERSION: '11'
9+
JAVA_DISTRO: 'zulu'
10+
611
jobs:
712
build:
813
name: Unit Test
@@ -12,15 +17,19 @@ jobs:
1217
uses: actions/checkout@v3
1318
with:
1419
fetch-depth: 0
15-
- name: Set up JDK 14
16-
uses: actions/setup-java@v1
20+
21+
- name: Setup Java
22+
uses: actions/setup-java@v3
1723
with:
18-
java-version: 14
19-
- name: Cache Maven packages
20-
uses: actions/cache@v2
24+
java-version: ${{ env.JAVA_VERSION }}
25+
distribution: ${{ env.JAVA_DISTRO }}
26+
27+
- name: Cache Maven
28+
uses: actions/cache@v3
2129
with:
22-
path: ~/.m2
30+
path: ~/.m2/repository
2331
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
2432
restore-keys: ${{ runner.os }}-m2
25-
- name: Test with Maven
26-
run: mvn -B test --file pom.xml
33+
34+
- name: Build
35+
run: ./mvnw --no-transfer-progress -B --file pom.xml verify

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
.mtj.tmp/
1212

1313
# Package Files #
14-
*.jar
1514
*.war
1615
*.nar
1716
*.ear
@@ -28,5 +27,8 @@ hs_err_pid*
2827
.project
2928

3029
# IntelliJ files
31-
.idea
32-
*.iml
30+
.idea/
31+
*.iml
32+
33+
# Maven output
34+
target/

.mvn/wrapper/maven-wrapper.jar

57.4 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -198,4 +199,4 @@
198199
distributed under the License is distributed on an "AS IS" BASIS,
199200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200201
See the License for the specific language governing permissions and
201-
limitations under the License.
202+
limitations under the License.

0 commit comments

Comments
 (0)