-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jponge/ci/release-workflow
Release workflow based on JReleaser and Maven Central compliance
- Loading branch information
Showing
3 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Inspired from https://foojay.io/today/how-to-release-a-java-module-with-jreleaser-to-maven-central-with-github-actions/ | ||
name: Publish a new release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Release version' | ||
required: true | ||
nextVersion: | ||
description: 'Next version after release (-SNAPSHOT will be added automatically)' | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Java setup | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Run a build of the code base before release | ||
run: ./mvnw --batch-mode --no-transfer-progress clean install | ||
- name: Set release version | ||
run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }} | ||
- name: Commit & Push changes | ||
uses: actions-js/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
message: "Releasing version ${{ github.event.inputs.version }}" | ||
- name: Release with JReleaser | ||
env: | ||
JRELEASER_TAG_NAME: ${{ github.event.inputs.version }} | ||
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} | ||
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} | ||
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} | ||
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }} | ||
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }} | ||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: ./release.sh | ||
- name: Set the next release version | ||
run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT | ||
- name: Commit & Push changes | ||
uses: actions-js/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
message: "Setting version ${{ github.event.inputs.nextVersion }}-SNAPSHOT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,40 @@ | |
<artifactId>runtimes-agent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<name>Red Hat Insights Java Agent</name> | ||
<description>Red Hat Insights Java Agent</description> | ||
<url>https://github.com/RedHatInsights/insights-java-agent</url> | ||
<inceptionYear>2023</inceptionYear> | ||
|
||
<licenses> | ||
<license> | ||
<name>The Apache License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Benjamin Evans</name> | ||
<email>[email protected]</email> | ||
<organization>Red Hat</organization> | ||
<organizationUrl>https://www.redhat.com/</organizationUrl> | ||
</developer> | ||
<developer> | ||
<id>ebaron</id> | ||
<name>Elliott Baron</name> | ||
<email>[email protected]</email> | ||
<organization>Red Hat</organization> | ||
<organizationUrl>https://www.redhat.com/</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/RedHatInsights/insights-java-agent.git</connection> | ||
<developerConnection>scm:git:ssh://github.com:RedHatInsights/insights-java-agent.git</developerConnection> | ||
<url>http://github.com/RedHatInsights/insights-java-agent/tree/main</url> | ||
</scm> | ||
|
||
<properties> | ||
<!-- <maven.compiler.release>8</maven.compiler.release>--> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
|
@@ -39,6 +73,9 @@ | |
<maven-install-plugin.version>3.1.0</maven-install-plugin.version> | ||
<maven-clean-plugin.version>3.2.0</maven-clean-plugin.version> | ||
<maven-resources-plugin.version>3.3.0</maven-resources-plugin.version> | ||
<maven-source-plugin.version>3.3.0</maven-source-plugin.version> | ||
<maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version> | ||
<jreleaser-maven-plugin.version>1.9.0</jreleaser-maven-plugin.version> | ||
|
||
<shade.prefix>com.redhat.insights.agent.shaded</shade.prefix> | ||
</properties> | ||
|
@@ -440,6 +477,7 @@ | |
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<attach>true</attach> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
|
@@ -515,5 +553,86 @@ | |
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>release</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jreleaser</groupId> | ||
<artifactId>jreleaser-maven-plugin</artifactId> | ||
<version>${jreleaser-maven-plugin.version}</version> | ||
<inherited>false</inherited> | ||
<configuration> | ||
<jreleaser> | ||
<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>target/staging-deploy</stagingRepositories> | ||
</maven-central> | ||
</nexus2> | ||
</maven> | ||
</deploy> | ||
</jreleaser> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>publication</id> | ||
<properties> | ||
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository> | ||
</properties> | ||
<build> | ||
<defaultGoal>deploy</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>${maven-javadoc-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<attach>true</attach> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>${maven-source-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
<configuration> | ||
<attach>true</attach> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
echo "📦 Staging artifacts..." | ||
./mvnw --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true | ||
|
||
echo "🚀 Releasing..." | ||
./mvnw --batch-mode --no-transfer-progress -Prelease jreleaser:full-release | ||
|
||
echo "🎉 Done!" |