Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create release workflow #414

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/actions/run-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "Run Tests"
description: "Runs the tests for the project"
runs:
using: "composite"
steps:
- name: Run Maven build
run: ./mvnw --no-transfer-progress clean compile test
shell: bash
13 changes: 13 additions & 0 deletions .github/actions/setup-jdk/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Setups JDK"
description: "Setups JDK 17"
runs:
using: "composite"
steps:
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
11 changes: 11 additions & 0 deletions .github/actions/setup-maven-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Setups Maven Cache"
description: "Setups Maven Cache for the project"
runs:
using: "composite"
steps:
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
54 changes: 54 additions & 0 deletions .github/workflows/changelog-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"max_tags_to_fetch": 200,
"max_pull_requests": 200,
"max_back_track_time_days": 365,
"exclude_merge_branches": [],
"sort": "ASC",
"template": "${{CHANGELOG}}",
"pr_template": "* ${{TITLE}} by @${{AUTHOR}} (#${{NUMBER}})",
"empty_template": "- no changes",
"categories": [
{
"title": "## Features",
"labels": [
"feature",
"enhancement"
]
},
{
"title": "## Fixes",
"labels": [
"fix",
"bug"
]
},
{
"title": "## Documentation",
"labels": [
"doc"
]
},
{
"title": "## Code-Cleanup",
"labels": [
"refactoring"
]
},
{
"title": "## Updated dependencies",
"labels": [
"dependencies"
]
}
],
"ignore_labels": [
"ignore"
],
"label_extractor": [],
"duplicate_filter": null,
"transformers": [],
"tag_resolver": {
"method": "semver"
},
"base_branches": []
}
16 changes: 6 additions & 10 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
cache: maven
- name: Run Maven build
run: ./mvnw --no-transfer-progress clean compile test

- uses: actions/checkout@v4
- uses: ./.github/actions/setup-jdk
- uses: ./.github/actions/setup-maven-cache
- uses: ./.github/actions/run-tests

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Release

on:
workflow_dispatch:
inputs:
GPG_PRIVATE_KEY:
description: 'The private key to sign the artifacts'
required: true
type: string
OSSRH_USERNAME:
description: 'The username to deploy to Maven Central'
required: true
type: string
OSSRH_TOKEN:
description: 'The token to deploy to Maven Central'
required: true
type: string

jobs:
build_and_deploy:
name: Build and Deploy to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-jdk
- uses: ./.github/actions/setup-maven-cache
- uses: ./.github/actions/run-tests

- name: Prepare for release
run: ./mvnw versions:set -DremoveSnapshot=true -DgenerateBackupPoms=false

- name: Get the version
id: get_version
run: echo ::set-output name=version::$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)

- name: Import GPG key
run: echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Deploy
run: ./mvnw -P release --batch-mode -DskipTests deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

- name: Upload JARs as artifact
uses: actions/upload-artifact@v2
with:
name: jars
path: ./target/*.jar

commit_and_tag:
name: Commit and Tag
needs: build_and_sign
runs-on: ubuntu-latest
steps:
- uses: ./.github/actions/setup-jdk

- name: Set version
run: ./mvnw versions:set -DnewVersion=${{ steps.get_version.outputs.version }} -DgenerateBackupPoms=false

- name: Update README.md
run: sed -i "s|<version>.*</version>|<version>${{ steps.get_version.outputs.version }}</version>|g" README.md

- name: Commit release POM and Tag
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Release ${{ steps.get_version.outputs.version }}" -a
git tag ${{ steps.get_version.outputs.version }}

- name: Set next development version
run: ./mvnw versions:set -DnextSnapshot=true -DgenerateBackupPoms=false

- name: Commit next snapshot
run: |
git commit -m "Next development version" -a

- name: Push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

create_github_release_and_attach_artifacts:
name: Create GitHub Release and attach artifacts
needs: commit_and_tag
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: ./target

- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/workflows/changelog-configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.output.version }}
release_name: Release ${{ steps.get_version.output.version }}
draft: false
prerelease: false
body: ${{steps.build_changelog.outputs.changelog}}

- name: Upload all jars to Release
run: |
for file in ./target/*.jar; do
echo "Uploading $file"
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @"$file" \
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $file)"
done
shell: bash
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
# under the License.
wrapperVersion=3.3.2
distributionType=bin
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
27 changes: 2 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ mvn jetty:run
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>0.19-neo4j-3.0.3</version>
<version>111</version>
</dependency>
</dependencies>
</profile>
Expand Down Expand Up @@ -497,33 +497,10 @@ mvn clean install site -Pneo-docs-build
Add the following repositories and dependency to your project's pom.xml:

~~~xml
<repositories>
<repository>
<id>neo4j-contrib-releases</id>
<url>https://raw.github.com/neo4j-contrib/m2/master/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>neo4j-contrib-snapshots</id>
<url>https://raw.github.com/neo4j-contrib/m2/master/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
[...]
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>0.30.0-neo4j-5.13.0</version>
<version>5.13.0</version>
</dependency>
~~~

Expand Down
79 changes: 64 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>neo4j-spatial</artifactId>
<groupId>org.neo4j</groupId>
<version>0.31.0-neo4j-5.19.0</version>
<version>5.19.0-SNAPSHOT</version>
<name>Neo4j - Spatial Components</name>
<description>Spatial utilities and components for Neo4j</description>
<url>https://components.neo4j.org/${project.artifactId}/${project.version}</url>
Expand Down Expand Up @@ -52,14 +52,6 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down Expand Up @@ -471,6 +463,67 @@
</repository>
</repositories>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<bestPractices>true</bestPractices>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>neo-docs-build</id>
<activation>
Expand Down Expand Up @@ -689,13 +742,9 @@
</reporting>

<distributionManagement>
<repository>
<id>repo</id>
<url>https://raw.github.com/neo4j-contrib/m2/master/releases</url>
</repository>
<snapshotRepository>
<id>snapshot-repo</id>
<url>https://raw.github.com/neo4j-contrib/m2/master/snapshots</url>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

Expand Down
Loading