Skip to content

Commit a8e17c3

Browse files
authored
Create release workflow (neo4j-contrib#414)
1 parent 68a0859 commit a8e17c3

File tree

9 files changed

+286
-51
lines changed

9 files changed

+286
-51
lines changed

.github/actions/run-tests/action.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: "Run Tests"
2+
description: "Runs the tests for the project"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Run Maven build
7+
run: ./mvnw --no-transfer-progress clean compile test
8+
shell: bash

.github/actions/setup-jdk/action.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Setups JDK"
2+
description: "Setups JDK 17"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Setup Java JDK
7+
uses: actions/setup-java@v4
8+
with:
9+
java-version: 17
10+
distribution: adopt
11+
server-id: ossrh
12+
server-username: MAVEN_USERNAME
13+
server-password: MAVEN_PASSWORD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Setups Maven Cache"
2+
description: "Setups Maven Cache for the project"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Cache Maven packages
7+
uses: actions/cache@v3
8+
with:
9+
path: ~/.m2
10+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
11+
restore-keys: ${{ runner.os }}-m2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"max_tags_to_fetch": 200,
3+
"max_pull_requests": 200,
4+
"max_back_track_time_days": 365,
5+
"exclude_merge_branches": [],
6+
"sort": "ASC",
7+
"template": "${{CHANGELOG}}",
8+
"pr_template": "* ${{TITLE}} by @${{AUTHOR}} (#${{NUMBER}})",
9+
"empty_template": "- no changes",
10+
"categories": [
11+
{
12+
"title": "## Features",
13+
"labels": [
14+
"feature",
15+
"enhancement"
16+
]
17+
},
18+
{
19+
"title": "## Fixes",
20+
"labels": [
21+
"fix",
22+
"bug"
23+
]
24+
},
25+
{
26+
"title": "## Documentation",
27+
"labels": [
28+
"doc"
29+
]
30+
},
31+
{
32+
"title": "## Code-Cleanup",
33+
"labels": [
34+
"refactoring"
35+
]
36+
},
37+
{
38+
"title": "## Updated dependencies",
39+
"labels": [
40+
"dependencies"
41+
]
42+
}
43+
],
44+
"ignore_labels": [
45+
"ignore"
46+
],
47+
"label_extractor": [],
48+
"duplicate_filter": null,
49+
"transformers": [],
50+
"tag_resolver": {
51+
"method": "semver"
52+
},
53+
"base_branches": []
54+
}

.github/workflows/pr-build.yaml

+6-10
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
15-
- name: Check out repository code
16-
uses: actions/checkout@v4
17-
- name: Setup Java JDK
18-
uses: actions/setup-java@v4
19-
with:
20-
java-version: 17
21-
distribution: adopt
22-
cache: maven
23-
- name: Run Maven build
24-
run: ./mvnw --no-transfer-progress clean compile test
15+
16+
- uses: actions/checkout@v4
17+
- uses: ./.github/actions/setup-jdk
18+
- uses: ./.github/actions/setup-maven-cache
19+
- uses: ./.github/actions/run-tests
20+
2521
- name: Publish Unit Test Results
2622
uses: EnricoMi/publish-unit-test-result-action@v2
2723
if: always()

.github/workflows/release.yaml

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
GPG_PRIVATE_KEY:
7+
description: 'The private key to sign the artifacts'
8+
required: true
9+
type: string
10+
OSSRH_USERNAME:
11+
description: 'The username to deploy to Maven Central'
12+
required: true
13+
type: string
14+
OSSRH_TOKEN:
15+
description: 'The token to deploy to Maven Central'
16+
required: true
17+
type: string
18+
19+
jobs:
20+
build_and_deploy:
21+
name: Build and Deploy to Maven Central
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: ./.github/actions/setup-jdk
26+
- uses: ./.github/actions/setup-maven-cache
27+
- uses: ./.github/actions/run-tests
28+
29+
- name: Prepare for release
30+
run: ./mvnw versions:set -DremoveSnapshot=true -DgenerateBackupPoms=false
31+
32+
- name: Get the version
33+
id: get_version
34+
run: echo ::set-output name=version::$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
35+
36+
- name: Import GPG key
37+
run: echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import
38+
env:
39+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
40+
41+
- name: Deploy
42+
run: ./mvnw -P release --batch-mode -DskipTests deploy
43+
env:
44+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
45+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
46+
47+
- name: Upload JARs as artifact
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: jars
51+
path: ./target/*.jar
52+
53+
commit_and_tag:
54+
name: Commit and Tag
55+
needs: build_and_sign
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: ./.github/actions/setup-jdk
59+
60+
- name: Set version
61+
run: ./mvnw versions:set -DnewVersion=${{ steps.get_version.outputs.version }} -DgenerateBackupPoms=false
62+
63+
- name: Update README.md
64+
run: sed -i "s|<version>.*</version>|<version>${{ steps.get_version.outputs.version }}</version>|g" README.md
65+
66+
- name: Commit release POM and Tag
67+
run: |
68+
git config --local user.email "[email protected]"
69+
git config --local user.name "GitHub Action"
70+
git commit -m "Release ${{ steps.get_version.outputs.version }}" -a
71+
git tag ${{ steps.get_version.outputs.version }}
72+
73+
- name: Set next development version
74+
run: ./mvnw versions:set -DnextSnapshot=true -DgenerateBackupPoms=false
75+
76+
- name: Commit next snapshot
77+
run: |
78+
git commit -m "Next development version" -a
79+
80+
- name: Push
81+
uses: ad-m/github-push-action@master
82+
with:
83+
github_token: ${{ secrets.GITHUB_TOKEN }}
84+
branch: ${{ github.ref }}
85+
86+
create_github_release_and_attach_artifacts:
87+
name: Create GitHub Release and attach artifacts
88+
needs: commit_and_tag
89+
runs-on: ubuntu-latest
90+
steps:
91+
- name: Download build artifacts
92+
uses: actions/download-artifact@v2
93+
with:
94+
name: build-artifacts
95+
path: ./target
96+
97+
- name: Build Changelog
98+
id: build_changelog
99+
uses: mikepenz/release-changelog-builder-action@v4
100+
with:
101+
configuration: ".github/workflows/changelog-configuration.json"
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Create GitHub Release
106+
id: create_release
107+
uses: actions/create-release@v1
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
with:
111+
tag_name: ${{ steps.get_version.output.version }}
112+
release_name: Release ${{ steps.get_version.output.version }}
113+
draft: false
114+
prerelease: false
115+
body: ${{steps.build_changelog.outputs.changelog}}
116+
117+
- name: Upload all jars to Release
118+
run: |
119+
for file in ./target/*.jar; do
120+
echo "Uploading $file"
121+
curl \
122+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
123+
-H "Content-Type: $(file -b --mime-type $file)" \
124+
--data-binary @"$file" \
125+
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $file)"
126+
done
127+
shell: bash

.mvn/wrapper/maven-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
# under the License.
1717
wrapperVersion=3.3.2
1818
distributionType=bin
19-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
2020
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar

README.md

+2-25
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ mvn jetty:run
350350
<dependency>
351351
<groupId>org.neo4j</groupId>
352352
<artifactId>neo4j-spatial</artifactId>
353-
<version>0.19-neo4j-3.0.3</version>
353+
<version>111</version>
354354
</dependency>
355355
</dependencies>
356356
</profile>
@@ -497,33 +497,10 @@ mvn clean install site -Pneo-docs-build
497497
Add the following repositories and dependency to your project's pom.xml:
498498

499499
~~~xml
500-
<repositories>
501-
<repository>
502-
<id>neo4j-contrib-releases</id>
503-
<url>https://raw.github.com/neo4j-contrib/m2/master/releases</url>
504-
<releases>
505-
<enabled>true</enabled>
506-
</releases>
507-
<snapshots>
508-
<enabled>false</enabled>
509-
</snapshots>
510-
</repository>
511-
<repository>
512-
<id>neo4j-contrib-snapshots</id>
513-
<url>https://raw.github.com/neo4j-contrib/m2/master/snapshots</url>
514-
<releases>
515-
<enabled>false</enabled>
516-
</releases>
517-
<snapshots>
518-
<enabled>true</enabled>
519-
</snapshots>
520-
</repository>
521-
</repositories>
522-
[...]
523500
<dependency>
524501
<groupId>org.neo4j</groupId>
525502
<artifactId>neo4j-spatial</artifactId>
526-
<version>0.30.0-neo4j-5.13.0</version>
503+
<version>5.13.0</version>
527504
</dependency>
528505
~~~
529506

pom.xml

+64-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<modelVersion>4.0.0</modelVersion>
2121
<artifactId>neo4j-spatial</artifactId>
2222
<groupId>org.neo4j</groupId>
23-
<version>0.31.0-neo4j-5.19.0</version>
23+
<version>5.19.0-SNAPSHOT</version>
2424
<name>Neo4j - Spatial Components</name>
2525
<description>Spatial utilities and components for Neo4j</description>
2626
<url>https://components.neo4j.org/${project.artifactId}/${project.version}</url>
@@ -52,14 +52,6 @@
5252
</compilerArgs>
5353
</configuration>
5454
</plugin>
55-
<plugin>
56-
<groupId>org.apache.maven.plugins</groupId>
57-
<artifactId>maven-gpg-plugin</artifactId>
58-
<version>1.6</version>
59-
<configuration>
60-
<skip>true</skip>
61-
</configuration>
62-
</plugin>
6355
<plugin>
6456
<groupId>org.apache.maven.plugins</groupId>
6557
<artifactId>maven-resources-plugin</artifactId>
@@ -471,6 +463,67 @@
471463
</repository>
472464
</repositories>
473465
<profiles>
466+
<profile>
467+
<id>release</id>
468+
<build>
469+
<plugins>
470+
<plugin>
471+
<groupId>org.apache.maven.plugins</groupId>
472+
<artifactId>maven-source-plugin</artifactId>
473+
<version>3.3.1</version>
474+
<executions>
475+
<execution>
476+
<id>attach-sources</id>
477+
<goals>
478+
<goal>jar-no-fork</goal>
479+
</goals>
480+
</execution>
481+
</executions>
482+
</plugin>
483+
<plugin>
484+
<groupId>org.apache.maven.plugins</groupId>
485+
<artifactId>maven-javadoc-plugin</artifactId>
486+
<version>3.6.3</version>
487+
<executions>
488+
<execution>
489+
<id>attach-javadocs</id>
490+
<goals>
491+
<goal>jar</goal>
492+
</goals>
493+
</execution>
494+
</executions>
495+
</plugin>
496+
<plugin>
497+
<groupId>org.apache.maven.plugins</groupId>
498+
<artifactId>maven-gpg-plugin</artifactId>
499+
<version>3.2.4</version>
500+
<configuration>
501+
<bestPractices>true</bestPractices>
502+
</configuration>
503+
<executions>
504+
<execution>
505+
<id>sign-artifacts</id>
506+
<phase>verify</phase>
507+
<goals>
508+
<goal>sign</goal>
509+
</goals>
510+
</execution>
511+
</executions>
512+
</plugin>
513+
<plugin>
514+
<groupId>org.sonatype.plugins</groupId>
515+
<artifactId>nexus-staging-maven-plugin</artifactId>
516+
<version>1.6.13</version>
517+
<extensions>true</extensions>
518+
<configuration>
519+
<serverId>ossrh</serverId>
520+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
521+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
522+
</configuration>
523+
</plugin>
524+
</plugins>
525+
</build>
526+
</profile>
474527
<profile>
475528
<id>neo-docs-build</id>
476529
<activation>
@@ -689,13 +742,9 @@
689742
</reporting>
690743

691744
<distributionManagement>
692-
<repository>
693-
<id>repo</id>
694-
<url>https://raw.github.com/neo4j-contrib/m2/master/releases</url>
695-
</repository>
696745
<snapshotRepository>
697-
<id>snapshot-repo</id>
698-
<url>https://raw.github.com/neo4j-contrib/m2/master/snapshots</url>
746+
<id>ossrh</id>
747+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
699748
</snapshotRepository>
700749
</distributionManagement>
701750

0 commit comments

Comments
 (0)