Skip to content

Commit 92e049f

Browse files
sbouchetadietish
andauthored
build: migrate from jenkins/nexus to github action/github maven repo (#341)
* build: migrate from jenkins/nexus to github action/github maven repo Signed-off-by: Stephane Bouchet <[email protected]> * build: migrate from jenkins/nexus to github action/github maven repo Signed-off-by: Stephane Bouchet <[email protected]> * fix: generated & added gradle verification-metadata Signed-off-by: Andre Dietisheim <[email protected]> --------- Signed-off-by: Stephane Bouchet <[email protected]> Signed-off-by: Andre Dietisheim <[email protected]> Co-authored-by: Andre Dietisheim <[email protected]>
1 parent b037665 commit 92e049f

File tree

7 files changed

+480
-43
lines changed

7 files changed

+480
-43
lines changed

.github/workflows/nightly.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Publish Nightly Build
2+
3+
on:
4+
schedule:
5+
- cron: '10 7 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
should-build-change:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
repo-cache-hit: ${{ steps.cache-last-commit.outputs.cache-hit }}
13+
steps:
14+
- name: Fetch Sources
15+
uses: actions/checkout@v4
16+
- run: |
17+
git rev-parse HEAD >> lastCommit
18+
- name: Check New Changes
19+
id: cache-last-commit
20+
uses: actions/cache@v4
21+
with:
22+
path: lastCommit
23+
key: lastCommit-${{ hashFiles('lastCommit') }}
24+
25+
release-snapshot-job:
26+
needs: should-build-change
27+
if: ${{ needs.should-build-change.outputs.repo-cache-hit != 'true' || github.event_name != 'schedule' }}
28+
name: Publish Snapshot
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
pull-requests: write
33+
steps:
34+
# Check out current repository
35+
- name: Fetch Sources
36+
uses: actions/checkout@v4
37+
38+
# Set up Java environment for the next steps
39+
- name: Setup Java
40+
uses: actions/setup-java@v4
41+
with:
42+
distribution: 'temurin'
43+
java-version: 17
44+
cache: 'gradle'
45+
46+
# Setup Gradle
47+
- name: Setup Gradle
48+
uses: gradle/actions/setup-gradle@v4
49+
50+
# Build plugin
51+
- name: Build Plugin
52+
run: ./gradlew build
53+
54+
# Publish to Maven repo
55+
- name: Checkout Maven Repo
56+
uses: actions/checkout@v4
57+
with:
58+
ref: repository
59+
path: mvn-repo
60+
61+
- name: Deploy to Maven Repository
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: |
65+
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
66+
./gradlew publish
67+
68+
git config --global user.email "[email protected]"
69+
git config --global user.name "GitHub Action Bot"
70+
mv build/repository mvn-repo
71+
git commit -am "Publish ${CURRENT_VERSION} (${{github.run_number}})"
72+
git push -f origin repository

.github/workflows/release.yml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Release
2+
run-name: Release ${{ inputs.release_version }}
3+
4+
#Only one job at a time
5+
concurrency: release
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
release_version:
11+
description: 'Release version'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
release:
17+
name: Publish
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
steps:
23+
# Check out current repository
24+
- name: Fetch Sources
25+
uses: actions/checkout@v4
26+
27+
# Set up Java environment for the next steps
28+
- name: Setup Java
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: 'temurin'
32+
java-version: 17
33+
cache: 'gradle'
34+
35+
# Setup Gradle
36+
- name: Setup Gradle
37+
uses: gradle/actions/setup-gradle@v4
38+
39+
- name: Tag Release
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
git config user.email "[email protected]"
44+
git config user.name "GitHub Action"
45+
if git diff --quiet; then
46+
echo "No changes to commit."
47+
else
48+
git commit -sam "chore(skip-release): set version to ${{ inputs.release_version }}"
49+
fi
50+
git tag ${{ inputs.release_version }}
51+
git push origin ${{ inputs.release_version }}
52+
53+
- name: Set Release Version
54+
shell: bash
55+
run: |
56+
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
57+
NEW_VERSION=${{ inputs.release_version }}
58+
awk -v current="$CURRENT_VERSION" -v new="$NEW_VERSION" 'BEGIN {FS=OFS="="} $1 == "projectVersion" { $2 = new }1' gradle.properties > tmpfile && mv tmpfile gradle.properties
59+
echo "Release version: $NEW_VERSION"
60+
echo "PLUGIN_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
61+
62+
# Publish the plugin to local release repo
63+
- name: Publish Library
64+
run: |
65+
./gradlew publish
66+
echo "Published $PLUGIN_VERSION."
67+
68+
# Set next SNAPSHOT version
69+
- name: Increment Plugin Version
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2)
74+
IFS="-" read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
75+
IFS="." read -ra VERSION_NUM <<< "${VERSION_PARTS[0]}"
76+
((VERSION_NUM[2]+=1))
77+
NEW_VERSION="${VERSION_NUM[0]}.${VERSION_NUM[1]}.${VERSION_NUM[2]}-SNAPSHOT"
78+
awk -v new_version="$NEW_VERSION" '/projectVersion=/{sub(/=.*/, "=" new_version)}1' gradle.properties > tmpfile && mv tmpfile gradle.properties
79+
echo "Set $NEW_VERSION in gradle.properties"
80+
git checkout -b $NEW_VERSION
81+
git commit -sam "chore(skip-release): set version to $NEW_VERSION"
82+
git push -u origin $NEW_VERSION
83+
84+
- name: Simple conventional changelog
85+
uses: redhat-developer/simple-conventional-changelog@0a6db1ac3910c2cf66f2e1a530951dba1ece8540 #0.0.12
86+
id: changelog
87+
with:
88+
token: ${{ secrets.GITHUB_TOKEN }}
89+
current-tag: ${{ inputs.release_version }}
90+
types-mapping: 'feat:Features,fix:Bug Fixes,docs:Documentation,refactor:Refactoring,build:Build,chore:Other'
91+
92+
# Create a new GitHub release
93+
- name: Create GitHub Release
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
run: |
97+
gh release create ${{ inputs.release_version }} \
98+
--title "${{ inputs.release_version }}" \
99+
--notes "$(cat << 'EOM'
100+
${{ steps.changelog.outputs.changelog }}
101+
EOM
102+
)"
103+
104+
- name: Upload Release Asset
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
run: gh release upload ${{ inputs.release_version }} ./build/libs/*.jar

Jenkinsfile

-29
This file was deleted.

build.gradle.kts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
plugins {
22
id("java-library")
33
id("maven-publish")
4-
alias(libs.plugins.gradleNexusPublishPlugin)
54
id("jacoco") // Code coverage
65
alias(libs.plugins.sonarqube) // SonarQube
76
}
@@ -89,16 +88,12 @@ publishing {
8988
}
9089
}
9190
}
92-
}
93-
94-
nexusPublishing {
95-
packageGroup.set("JBoss Releases Staging Profile")
9691
repositories {
97-
create("jbossNexus") {
98-
nexusUrl.set(uri("https://repository.jboss.org/nexus/service/local/"))
99-
snapshotRepositoryUrl.set(uri("https://repository.jboss.org/nexus/content/repositories/snapshots/"))
100-
username.set(project.properties["nexusUser"].toString()) // defaults to project.properties["myNexusUsername"]
101-
password.set(project.properties["nexusPassword"].toString()) // defaults to project.properties["myNexusPassword"]
92+
maven {
93+
val baseUrl = layout.buildDirectory.dir("repository/").get()
94+
val releasesRepoUrl = baseUrl.dir("releases")
95+
val snapshotsRepoUrl = baseUrl.dir("snapshots")
96+
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
10297
}
10398
}
10499
}

gradle.properties

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
projectVersion=0.4.4-SNAPSHOT
2-
nexusUser=invalid
3-
nexusPassword=invalid
42

53
# Gradle Releases -> https://github.com/gradle/gradle/releases
64
gradleVersion=8.5

gradle/libs.versions.toml

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ kotlin = "2.1.0"
55
junit-jupiter = "5.11.3"
66

77
# plugins
8-
gradleNexusPublishPlugin = "2.0.0"
98
sonarqube = "5.1.0.4882"
109

1110
[libraries]
@@ -15,5 +14,4 @@ remote-robot = { group = "com.intellij.remoterobot", name = "remote-robot", vers
1514
remote-fixtures = { group = "com.intellij.remoterobot", name = "remote-fixtures", version.ref = "remote-robot" }
1615

1716
[plugins]
18-
gradleNexusPublishPlugin = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradleNexusPublishPlugin" }
1917
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }

0 commit comments

Comments
 (0)