Skip to content

Commit

Permalink
[chore]: add auto release mvn package
Browse files Browse the repository at this point in the history
Signed-off-by: stone1100 <[email protected]>
  • Loading branch information
stone1100 committed Apr 16, 2023
1 parent 5b69d7a commit b76f11b
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 16 deletions.
29 changes: 29 additions & 0 deletions .github/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"categories":[
{
"title":"### 🚀 New features",
"labels":[
"feature",
"enhancement"
]
},
{
"title":"### 🐛 Bug fixes",
"labels":[
"bug"
]
},
{
"title":"### 💬 Others",
"exclude_labels":[
"feature",
"enhancement",
"bug"
]
}
],
"ignore_labels":[
"release_bot"
],
"pr_template":"- ${{TITLE}} by @${{AUTHOR}} in #${{NUMBER}}"
}
63 changes: 51 additions & 12 deletions .github/workflows/publish_ossrh.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
name: Pushlish Java Client to OSSRH
on:
workflow_dispatch:
release:
types: [released]
push:
tags:
- "v*.*.*"

jobs:
test-with-coverage:
name: Publish package
runs-on: ubuntu-latest
steps:
- name: get latest release with tag
id: latestrelease
run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/lindb/client_java/releases/latest | jq '.tag_name' | sed 's/\"//g')"
- name: confirm release tag
run: |
echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: ${{ steps.latestrelease.outputs.releasetag }}
ref: ${{ github.ref_name }}
- name: Modify version
id: version
run: |
VERSION=${{ github.ref_name }}
echo "version=${VERSION:1}" >> $GITHUB_OUTPUT
- name: Generate release changelog
id: generate_changelog
uses: mikepenz/[email protected]
with:
configuration: ".github/configuration.json"
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
Expand All @@ -31,10 +35,45 @@ jobs:
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key pcassphrase

- name: Modify pom version
run: |
mvn versions:set -DnewVersion=${{ steps.version.outputs.version }}
- name: Publish package
run: mvn --batch-mode deploy -Dmaven.exec.skip=true
run: mvn --batch-mode clean deploy -Dmaven.exec.skip=true
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create release
uses: softprops/action-gh-release@v1
if: github.event_name != 'workflow_dispatch'
with:
release_name: ${{ github.ref_name }}
body: "${{ steps.generate_changelog.outputs.changelog }}"
- name: Checkout main
run: |
git fetch origin main
git checkout main
mvn versions:set -DnewVersion=${{ steps.version.outputs.version }}
- name: Create changelog pull request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: "[chore]: modify version(${{ github.ref_name }})"
branch: versions
signoff: true
delete-branch: true
title: "[chore]: modify version(${{ github.ref_name }})"
body: |
Modify pom.xml version
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
release_bot
- name: Auto merge pull request
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: rebase

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target/*
*.iml
.DS_Store
.factorypath
pom.xml.versionsBackup

# Log file
*.log
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ Download the latest version:
<dependency>
<groupId>io.lindb</groupId>
<artifactId>lindb-client</artifactId>
<version>0.1.0</version>
<version>0.0.4</version>
</dependency>
```
##### Or when using Gradle:

```groovy
dependencies {
implementation "io.lindb:lindb-client:0.1.0"
implementation "io.lindb:lindb-client:0.0.4"
}
```

Expand Down
24 changes: 23 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>lindb-client</artifactId>
<groupId>io.lindb</groupId>
<version>0.1.0</version>
<version>v0.0.3</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<name>LinDB Java Client SDK</name>
Expand Down Expand Up @@ -286,6 +286,28 @@
</gpgArguments>
</configuration>
</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>
<description>${project.version}</description>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
<executions>
<execution>
<id>deploy-to-sonatype</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
<goal>release</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lindb/client/internal/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class HttpClient {
/**
* http user agent information
*/
protected final static String USER_AGENT = String.format("lindb-client-java/%s (%s; %s) Java/%s", "0.1.0",
protected final static String USER_AGENT = String.format("lindb-client-java/%s (%s; %s) Java/%s", "0.0.4",
System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("java.version"));
/**
* Json media type
Expand Down

0 comments on commit b76f11b

Please sign in to comment.