Skip to content

Commit

Permalink
Release update
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling committed Feb 18, 2024
1 parent 0e3d1ee commit a9b9da2
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 128 deletions.
102 changes: 67 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,89 @@
name: Release

on:
push:
tags:
- v*
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
next:
description: 'Next version'
required: false

env:
JAVA_VERSION: '11'
JAVA_DISTRO: 'temurin'

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Version
id: version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Maven
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven

- name: Release
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Set release version
id: version
run: |
BRANCH="oss-quickstart-${{ github.event.inputs.version }}"
RELEASE_VERSION=${{ github.event.inputs.version }}
NEXT_VERSION=${{ github.event.inputs.next }}
PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'`
COMPUTED_NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT"
if [ -z $NEXT_VERSION ]
then
NEXT_VERSION=$COMPUTED_NEXT_VERSION
fi
git checkout -b $BRANCH
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
git config --global user.email "moditect-release-bot@moditect.org"
git config --global user.name "moditect-release-bot"
git commit -a -m "Releasing version $RELEASE_VERSION"
git push origin $BRANCH
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_ENV
- name: Stage
run: |
export GPG_TTY=$(tty)
export MAVEN_OPTS=--illegal-access=permit
mvn --no-transfer-progress -B --file pom.xml \
./mvnw -ntp -B --file pom.xml \
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \
-Dmaven.site.skip=true -Drelease=true deploy
-Dmaven.site.skip=true -Drelease=true -Ppublication,stage
- name: Release to GitHub
- name: Release
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_BRANCH: ${{ env.BRANCH }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./mvnw -ntp -B --file pom.xml -Pjreleaser jreleaser:release
- name: JReleaser output
if: always()
uses: actions/upload-artifact@v4
with:
name: jreleaser-release
path: |
parent/target/jreleaser/trace.log
parent/target/jreleaser/output.properties
- name: Set next version
run: |
mvn -B --file pom.xml -pl :ossquickstart-aggregator -Pjreleaser jreleaser:release
./mvnw -ntp -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }}
git config --global user.email "moditect-release-bot@moditect.org"
git config --global user.name "moditect-release-bot"
git commit -a -m "Next version ${{ env.NEXT_VERSION }}"
git push origin ${{ env.BRANCH }}
85 changes: 0 additions & 85 deletions .github/workflows/trigger.yml

This file was deleted.

54 changes: 46 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@
</modules>

<profiles>
<profile>
<id>stage</id>
<properties>
<altDeploymentRepository>local::file:${maven.multiModuleProjectDirectory}/target/staging-deploy</altDeploymentRepository>
</properties>
<build>
<defaultGoal>deploy</defaultGoal>
</build>
</profile>
<profile>
<id>jreleaser</id>
<build>
Expand All @@ -171,22 +180,51 @@
<version>1.10.0</version>
<inherited>false</inherited>
<configuration>
<gitRootSearch>true</gitRootSearch>
<jreleaser>
<project>
<name>oss-quickstart</name>
<links>
<homepage>https://github.com/moditect/oss-quickstart</homepage>
<documentation>https://github.com/moditect/oss-quickstart</documentation>
</links>
</project>
<signing>
<active>ALWAYS</active>
<armored>true</armored>
</signing>
<deploy>
<maven>
<nexus2>
<maven-central>
<active>ALWAYS</active>
<url>https://oss.sonatype.org/service/local</url>
<snapshotUrl>https://oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
<closeRepository>true</closeRepository>
<releaseRepository>true</releaseRepository>
<stagingRepositories>${maven.multiModuleProjectDirectory}/target/staging-deploy</stagingRepositories>
</maven-central>
</nexus2>
</maven>
</deploy>
<release>
<github>
<skipTag>true</skipTag>
<tagName>{{projectVersion}}</tagName>
<releaseName>{{projectVersion}}</releaseName>
<overwrite>true</overwrite>
<issues>
<enabled>true</enabled>
</issues>
<changelog>
<formatted>ALWAYS</formatted>
<preset>gitmoji</preset>
<format>- {{commitShortHash}} {{commitTitle}}</format>
<formatted>ALWAYS</formatted>
<preset>conventional-commits</preset>
<skipMergeCommits>true</skipMergeCommits>
<contributors>
<format>* {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}</format>
<format>- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}</format>
</contributors>
<hide>
<contributors>
<contributor>GitHub</contributor>
<contributor>bot</contributor>
</contributors>
<contributors>GitHub,dependabot</contributors>
</hide>
</changelog>
</github>
Expand Down

0 comments on commit a9b9da2

Please sign in to comment.