Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jul 24, 2024
1 parent 2b92bc1 commit 666d06a
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 13 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Manual Maven Release

on:
workflow_dispatch:
inputs:
version:
description: The version to release (will be inferred from the pom version by default).
required: false
next-version:
description: The next developement version (will be inferred from the pom version by default).
required: false
java-version:
description: The java version to use
required: false
default: 22
distribution:
description: The java distribution to use.
required: false
default: temurin
maven-version:
description: The Maven version to use
required: false
default: 3.9.8

jobs:
release:
name: Release to Maven Central
runs-on: ubuntu-latest
steps:

- name: Checkout ${{ github.ref_name }}
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ github.event.inputs.distribution }}
java-version: ${{ github.event.inputs.java-version }}
cache: maven
server-id: central
server-username: MAVEN_USER
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY_GITHUB_TECHUSER }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ github.event.inputs.maven-version }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY_GITHUB_TECHUSER }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
fingerprint: ${{ secrets.MAVEN_GPG_KEY_FINGERPRINT }}

- name: Diag
run: |
echo "====================="
echo " Maven "
echo "====================="
mvn -v
echo "====================="
echo " Global settings "
echo "====================="
cat $HOME/.m2/settings.xml
echo ""
echo "====================="
echo " Git config "
echo "====================="
git config -l --global
- name: Release preparation
id: pre-release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install valeriobelli/gh-milestone
version=$(mvn -q -DforceStdout help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Release
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_GPG_KEY_FINGERPRINT: ${{ secrets.MAVEN_GPG_KEY_FINGERPRINT }}
MAVEN_USER: ${{ secrets.NEXUS_USER }}
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: |
mvn -B release:prepare release:perform -Darguments="-DskipTests" -DreleaseVersion=${{ github.event.inputs.version }} -DdevelopmentVersion=${{ github.event.inputs.next-version }}
- name: Post release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
version=${{ steps.pre-release.outputs.version }}
echo "Trying to find milestone $version"
milestone=$(gh milestone list --json id,title,state --jq "map_values(select(.title == \"${version}\" and .state == \"OPEN\")).[].number")
if [ ! -z "$milestone" ]; then
echo "Found milestone $version, closing it"
gh milestone edit $milestone --state closed
fi
version=$(mvn -q -DforceStdout help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p')
echo "Preparing development $version"
echo "Trying to find milestone $version"
milestone=$(gh milestone list --json id,title,state --jq "map_values(select(.title == \"${version}\" and .state == \"OPEN\")).[].number")
if [ -z "$milestone" ]; then
echo "Creating milestone $version"
gh milestone create --title $version
fi
name=$(mvn -q -DforceStdout help:evaluate -N -Dexpression=project.name)
version=${{ steps.pre-release.outputs.VERSION }}
tag=$(git describe --tags --abbrev=0)
echo "Creating release \"$name $version\" from tag $tag"
gh release create $tag --verify-tag --notes-from-tag --title "$name $version"
27 changes: 14 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<artifactId>jline-parent</artifactId>
<version>3.27.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JLine Parent</name>
<name>JLine</name>
<description>JLine</description>
<url>https://github.com/jline/jline3</url>

Expand Down Expand Up @@ -83,11 +83,6 @@
<url>https://github.com/jline/jline3/issues</url>
</issueManagement>

<ciManagement>
<system>travis</system>
<url>https://travis-ci.org/jline/jline3</url>
</ciManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2024-07-17T18:32:16Z</project.build.outputTimestamp>
Expand Down Expand Up @@ -443,12 +438,9 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<deployAtEnd>true</deployAtEnd>
</configuration>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.5.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -534,7 +526,7 @@
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
<passphrase>${gpg.passphrase}</passphrase>
<bestPractices>true</bestPractices>
<useAgent>true</useAgent>
</configuration>
</execution>
Expand Down Expand Up @@ -710,6 +702,15 @@
</configuration>
</plugin>

<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>

<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
Expand Down

0 comments on commit 666d06a

Please sign in to comment.