Skip to content

Commit 5a7c26a

Browse files
authored
Merge branch 'main' into all_in_fix
2 parents a20c13f + 15b2805 commit 5a7c26a

File tree

6 files changed

+123
-18
lines changed

6 files changed

+123
-18
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches: [ main, master ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
environment: snapshot
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up JDK 8
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: '8'
17+
distribution: 'temurin'
18+
cache: 'gradle'
19+
- name: Setup Gradle
20+
uses: gradle/gradle-build-action@v2
21+
with:
22+
cache-read-only: false
23+
gradle-home-cache-cleanup: true
24+
- name: Build
25+
run: ./gradlew build

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
environment: production
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up JDK 8
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: '8'
17+
distribution: 'temurin'
18+
cache: 'gradle'
19+
- name: Setup Gradle
20+
uses: gradle/gradle-build-action@v2
21+
- name: Set release version
22+
run: |
23+
# Remove -SNAPSHOT from version
24+
sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle
25+
- name: Publish package
26+
env:
27+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
28+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
29+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
30+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
31+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
32+
run: |
33+
./gradlew build uploadArchives
34+
- name: Bump version
35+
id: bump_version
36+
run: |
37+
# Get current version without SNAPSHOT
38+
CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/')
39+
40+
# Split into parts
41+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
42+
43+
# Increment patch version
44+
NEXT_PATCH=$((VERSION_PARTS[2] + 1))
45+
46+
# Create new version
47+
NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT"
48+
49+
# Update build.gradle
50+
sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle
51+
52+
# Make the new version available to other steps
53+
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
54+
- name: Commit version bump
55+
env:
56+
NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }}
57+
run: |
58+
git config user.name "github-actions[bot]"
59+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
60+
git add --all
61+
git commit -m "Prepare version $NEXT_VERSION for development [skip ci]"
62+
git pull --rebase origin main
63+
git push origin HEAD:main

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
.idea/
33
out/
44
build/
5-
.DS_Store
5+
.DS_Store
6+
secring.gpg
7+
.vscode

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java temurin-8.0.392+8

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,3 @@ assert JsonLogic.truthy("Hello world!") == true;
5656

5757
// etc...
5858
```
59-
60-
## Building a Release
61-
62-
For now, there is no CI pipeline.
63-
Changes do not happen frequently enough to require them.
64-
65-
1. Remove the `-SNAPSHOT` from the version in `build.gradle`.
66-
2. Update the `README.md` installation instructions to use the new version.
67-
3. Add and commit the changes.
68-
4. Create a git tag (`git tag v{VERSION}`) and push: `git push && git push --tags`.
69-
5. Run `./gradlew clean build uploadArchives` to push to Sonatype.
70-
6. Bump the version in the `build.gradle` file and add `-SNAPSHOT` to it.
71-
7. Add and commit the changes.

build.gradle

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group "io.github.jamsesso"
8-
version "1.0.8-SNAPSHOT"
8+
version "1.0.9-SNAPSHOT"
99

1010
sourceCompatibility = 1.8
1111
targetCompatibility = 1.8
@@ -29,25 +29,51 @@ task sourcesJar(type: Jar) {
2929
from sourceSets.main.allSource
3030
}
3131

32+
test {
33+
testLogging {
34+
events "passed", "skipped", "failed"
35+
exceptionFormat "full"
36+
showStandardStreams = true
37+
}
38+
}
39+
3240
artifacts {
3341
archives jar, javadocJar, sourcesJar
3442
}
3543

44+
def getSonatypeUsername() {
45+
return System.getenv('SONATYPE_USERNAME')
46+
}
47+
48+
def getSonatypePassword() {
49+
return System.getenv('SONATYPE_PASSWORD')
50+
}
51+
52+
def hasCredentials() {
53+
def result = getSonatypeUsername() != null && getSonatypePassword() != null
54+
if (!result) {
55+
println "Cannot publish package since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables."
56+
}
57+
return result
58+
}
59+
3660
signing {
61+
required { gradle.taskGraph.hasTask("uploadArchives") }
62+
useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD'))
3763
sign configurations.archives
3864
}
3965

4066
uploadArchives {
4167
repositories {
4268
mavenDeployer {
43-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
69+
beforeDeployment { deployment -> signing.signPom(deployment) }
4470

4571
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
46-
authentication(userName: sonatypeUsername, password: sonatypePassword)
72+
authentication(userName: getSonatypeUsername(), password: getSonatypePassword())
4773
}
4874

4975
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
50-
authentication(userName: sonatypeUsername, password: sonatypePassword)
76+
authentication(userName: getSonatypeUsername(), password: getSonatypePassword())
5177
}
5278

5379
pom.project {
@@ -80,4 +106,5 @@ uploadArchives {
80106
}
81107
}
82108
}
109+
onlyIf { hasCredentials() }
83110
}

0 commit comments

Comments
 (0)