Skip to content

Commit 1e2ee62

Browse files
committed
Updating release and publishing logic
1 parent 0b5c794 commit 1e2ee62

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

.github/workflows/publish.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@ name: Package and publish
22

33
on:
44
release:
5-
types: [created]
5+
types: [published]
66

77
jobs:
88
build:
99
runs-on: ubuntu-latest
1010
permissions:
11-
contents: read
11+
contents: write
1212
packages: write
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
1518
- name: Set up JDK 17
1619
uses: actions/setup-java@v4
1720
with:
1821
java-version: "17"
1922
distribution: "temurin"
2023
server-id: github
21-
settings-path: ${{ github.workspace }} # location for the settings.xml file
24+
settings-path: ${{ github.workspace }}
2225

2326
- name: Setup Gradle
2427
uses: gradle/actions/setup-gradle@v4
2528

29+
- name: Extract version from tag
30+
run: |
31+
VERSION=${GITHUB_REF#refs/tags/v}
32+
echo "VERSION=$VERSION" >> $GITHUB_ENV
33+
34+
- name: Update version
35+
run: |
36+
sed -i "s/version=.*/version=$VERSION/" gradle.properties
37+
2638
- name: Build with Gradle
2739
run: ./gradlew s2:build
2840

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
org.gradle.parallel=true
55
org.gradle.caching=true
66

7+
group=org.twelvehart
8+
version=0.0.2-SNAPSHOT
9+
10+
# Release plugin configuration
11+
release.useAutomaticVersion=true
12+
release.releaseVersion=0.0.2
13+
release.newVersion=0.0.3-SNAPSHOT

s2/build.gradle.kts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id("buildlogic.java-library-conventions")
33
id("com.google.protobuf") version "0.9.4"
44
id("maven-publish")
5+
id("net.researchgate.release") version "3.1.0"
56
}
67

78
repositories {
@@ -77,9 +78,6 @@ java {
7778
publishing {
7879
publications {
7980
create<MavenPublication>("maven") {
80-
groupId = "org.twelvehart"
81-
artifactId = "s2"
82-
version = "0.0.1"
8381
from(components["java"])
8482
}
8583
repositories {
@@ -93,4 +91,17 @@ publishing {
9391
}
9492
}
9593
}
94+
}
95+
96+
release {
97+
git {
98+
requireBranch.set("main")
99+
pushToRemote.set("origin")
100+
signTag.set(false)
101+
tagTemplate.set("v\${version}")
102+
}
103+
}
104+
105+
tasks.afterReleaseBuild {
106+
dependsOn(tasks.publish)
96107
}

0 commit comments

Comments
 (0)