From 44d581bf5ce7d5aaf2366b38aac7c989e7790096 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Tue, 11 Mar 2025 10:22:14 -0300 Subject: [PATCH 01/20] Initial commit for Github actions --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3512ca4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build & Test + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + cache: 'gradle' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + cache-read-only: false + gradle-home-cache-cleanup: true + + - name: Build + run: ./gradlew build + + - name: Test + run: ./gradlew test \ No newline at end of file From 90baaf9c7bbe62b718baeef9ca589b0bdb6280b8 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Tue, 11 Mar 2025 13:29:26 -0300 Subject: [PATCH 02/20] Make uploadArchives conditional on the presence of Sonatype credentials --- .tool-versions | 1 + build.gradle | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..3fbb92b --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +java temurin-8.0.392+8 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 24a6ec7..8943d18 100644 --- a/build.gradle +++ b/build.gradle @@ -37,17 +37,25 @@ signing { sign configurations.archives } +def getSonatypeUsername() { + return System.getenv('SONATYPE_USERNAME') +} + +def getSonatypePassword() { + return System.getenv('SONATYPE_PASSWORD') +} + uploadArchives { repositories { mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + beforeDeployment { deployment -> signing.signPom(deployment) } repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: sonatypeUsername, password: sonatypePassword) + authentication(userName: getSonatypeUsername(), password: getSonatypePassword()) } snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: sonatypeUsername, password: sonatypePassword) + authentication(userName: getSonatypeUsername(), password: getSonatypePassword()) } pom.project { @@ -81,3 +89,12 @@ uploadArchives { } } } + +// Add a check to ensure credentials are present before upload +uploadArchives.onlyIf { + def hasCredentials = getSonatypeUsername() != null && getSonatypePassword() != null + if (!hasCredentials) { + println "Skipping uploadArchives since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables." + } + return hasCredentials +} From cd2f3f5a8c610d2a7c3361b868f94d65c275c0da Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Tue, 11 Mar 2025 14:03:08 -0300 Subject: [PATCH 03/20] Turn off signing conditionally --- .vscode/settings.json | 3 +++ build.gradle | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e0f15db --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8943d18..f4d9dcc 100644 --- a/build.gradle +++ b/build.gradle @@ -91,10 +91,13 @@ uploadArchives { } // Add a check to ensure credentials are present before upload -uploadArchives.onlyIf { - def hasCredentials = getSonatypeUsername() != null && getSonatypePassword() != null - if (!hasCredentials) { - println "Skipping uploadArchives since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables." - } - return hasCredentials +def hasCredentials() { + def result = getSonatypeUsername() != null && getSonatypePassword() != null + if (!result) { + println "Skipping uploadArchives since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables." + } + return result } + +uploadArchives.onlyIf hasCredentials +signing.onlyIf hasCredentials From a63f0795fdf30a274003427fe4b74147aee3a434 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Tue, 11 Mar 2025 14:11:37 -0300 Subject: [PATCH 04/20] Really make signing optional --- build.gradle | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index f4d9dcc..20f26f1 100644 --- a/build.gradle +++ b/build.gradle @@ -33,10 +33,6 @@ artifacts { archives jar, javadocJar, sourcesJar } -signing { - sign configurations.archives -} - def getSonatypeUsername() { return System.getenv('SONATYPE_USERNAME') } @@ -45,6 +41,19 @@ def getSonatypePassword() { return System.getenv('SONATYPE_PASSWORD') } +def hasCredentials() { + def result = getSonatypeUsername() != null && getSonatypePassword() != null + if (!result) { + println "Cannot publish package since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables." + } + return result +} + +signing { + setRequired { hasCredentials() } + sign configurations.archives +} + uploadArchives { repositories { mavenDeployer { @@ -88,16 +97,5 @@ uploadArchives { } } } + onlyIf { hasCredentials() } } - -// Add a check to ensure credentials are present before upload -def hasCredentials() { - def result = getSonatypeUsername() != null && getSonatypePassword() != null - if (!result) { - println "Skipping uploadArchives since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables." - } - return result -} - -uploadArchives.onlyIf hasCredentials -signing.onlyIf hasCredentials From 90f3b56eb737309c6872e093666ac715f74e2b60 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Tue, 11 Mar 2025 14:17:22 -0300 Subject: [PATCH 05/20] Add testing output --- .github/workflows/build.yml | 3 --- build.gradle | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3512ca4..04b59cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,3 @@ jobs: - name: Build run: ./gradlew build - - - name: Test - run: ./gradlew test \ No newline at end of file diff --git a/build.gradle b/build.gradle index 20f26f1..8a34a43 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,14 @@ task sourcesJar(type: Jar) { from sourceSets.main.allSource } +test { + testLogging { + events "passed", "skipped", "failed" + exceptionFormat "full" + showStandardStreams = true + } +} + artifacts { archives jar, javadocJar, sourcesJar } From 334b2f82713716db03b54561ae09a6c0f7eec16e Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Wed, 12 Mar 2025 09:51:36 -0300 Subject: [PATCH 06/20] Test publish step --- .github/workflows/build.yml | 74 +++++++++++++++++++++++++++++++++++-- .gitignore | 3 +- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04b59cc..c99fcb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,22 +9,88 @@ on: jobs: build: runs-on: ubuntu-latest - + environment: snapshot steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 uses: actions/setup-java@v3 with: java-version: '8' distribution: 'temurin' cache: 'gradle' - - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: cache-read-only: false gradle-home-cache-cleanup: true - - name: Build run: ./gradlew build + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: build/ + + publish: + needs: build + # if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + runs-on: ubuntu-latest + environment: production + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + cache: 'gradle' + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + path: build/ + # - name: Set release version + # run: | + # # Remove -SNAPSHOT from version + # sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle + - name: Publish package + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + run: | + echo "${{ secrets.SIGNING_KEY }}" | base64 -d > signing.gpg + ./gradlew uploadArchives -Psigning.secretKeyRingFile=$(pwd)/signing.gpg -Psigning.keyId=$SIGNING_KEY_ID -Psigning.password=$SIGNING_PASSWORD + - name: Bump version + id: bump_version + run: | + # Get current version without SNAPSHOT + CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/') + + # Split into parts + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + + # Increment patch version + NEXT_PATCH=$((VERSION_PARTS[2] + 1)) + + # Create new version + NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT" + + # Update build.gradle + sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle + + # Make the new version available to other steps + echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT + - name: Commit version bump + env: + NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add --all + git commit -m "Prepare version $NEXT_VERSION for development [skip ci]" + git push \ No newline at end of file diff --git a/.gitignore b/.gitignore index b75596a..2398de1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .idea/ out/ build/ -.DS_Store \ No newline at end of file +.DS_Store +secring.gpg \ No newline at end of file From 9123a9b41dc0b80d30cdeb46c6760e7326ab729c Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Wed, 12 Mar 2025 09:55:13 -0300 Subject: [PATCH 07/20] Attempt to fix path for upload-artifacts action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c99fcb8..8dd8951 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: build-artifacts - path: build/ + path: build/**/* publish: needs: build From e1e5cd63a976d3fc5033e298ac1971ff9a42f150 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Wed, 12 Mar 2025 09:59:06 -0300 Subject: [PATCH 08/20] Use v4 for upload/download-artifacts --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8dd8951..0178c0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,10 +26,10 @@ jobs: - name: Build run: ./gradlew build - name: Upload build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build-artifacts - path: build/**/* + path: build/ publish: needs: build @@ -47,7 +47,7 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Download build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: build-artifacts path: build/ From 4573064a104d99e979f571f6f736a30df6fc0d4c Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Wed, 12 Mar 2025 11:02:12 -0300 Subject: [PATCH 09/20] Fix signing logic to use in memory keys --- .github/workflows/build.yml | 5 +++-- build.gradle | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0178c0a..82c66ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,8 @@ jobs: with: name: build-artifacts path: build/ + - name: Debug build artifacts (delete me) + run: ls -la build/ # - name: Set release version # run: | # # Remove -SNAPSHOT from version @@ -63,8 +65,7 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} run: | - echo "${{ secrets.SIGNING_KEY }}" | base64 -d > signing.gpg - ./gradlew uploadArchives -Psigning.secretKeyRingFile=$(pwd)/signing.gpg -Psigning.keyId=$SIGNING_KEY_ID -Psigning.password=$SIGNING_PASSWORD + ./gradlew uploadArchives - name: Bump version id: bump_version run: | diff --git a/build.gradle b/build.gradle index 8a34a43..b73439b 100644 --- a/build.gradle +++ b/build.gradle @@ -58,7 +58,8 @@ def hasCredentials() { } signing { - setRequired { hasCredentials() } + required { gradle.taskGraph.hasTask("uploadArchives") } + useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD')) sign configurations.archives } From 49459b0cfdc4fc8512c89296050a59a23c938774 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Wed, 12 Mar 2025 11:14:44 -0300 Subject: [PATCH 10/20] Fix push logic in the bump version step --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82c66ba..8f84256 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build & Test +name: Build on: push: @@ -33,6 +33,7 @@ jobs: publish: needs: build + # TODO # if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') runs-on: ubuntu-latest environment: production @@ -51,8 +52,7 @@ jobs: with: name: build-artifacts path: build/ - - name: Debug build artifacts (delete me) - run: ls -la build/ + # TODO # - name: Set release version # run: | # # Remove -SNAPSHOT from version @@ -94,4 +94,4 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add --all git commit -m "Prepare version $NEXT_VERSION for development [skip ci]" - git push \ No newline at end of file + git push origin HEAD:github_actions #TODO \ No newline at end of file From 983c1891cb880a172195f900912d85af737581f7 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:31:43 -0300 Subject: [PATCH 11/20] Use checkout@v4 --- .github/workflows/build.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f84256..b8e5895 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest environment: snapshot steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 8 uses: actions/setup-java@v3 with: @@ -89,9 +89,11 @@ jobs: - name: Commit version bump env: NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} + BRANCH_NAME: ${{ github.ref_name }} run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git pull --rebase origin $BRANCH_NAME git add --all git commit -m "Prepare version $NEXT_VERSION for development [skip ci]" - git push origin HEAD:github_actions #TODO \ No newline at end of file + git push origin HEAD:$BRANCH_NAME \ No newline at end of file From 661d50a3bfea2d0c81180e99c0012311316c6250 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:38:35 -0300 Subject: [PATCH 12/20] Add a rebase before committing --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8e5895..9d89b6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,9 +91,9 @@ jobs: NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} BRANCH_NAME: ${{ github.ref_name }} run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - git pull --rebase origin $BRANCH_NAME + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add --all git commit -m "Prepare version $NEXT_VERSION for development [skip ci]" + git pull --rebase origin $BRANCH_NAME git push origin HEAD:$BRANCH_NAME \ No newline at end of file From 8d2ea2bc45c72310822d82123d150e2f51f0c1b9 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:40:57 -0300 Subject: [PATCH 13/20] Hard-code branch name... --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d89b6d..0fc0550 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,7 +89,7 @@ jobs: - name: Commit version bump env: NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} - BRANCH_NAME: ${{ github.ref_name }} + BRANCH_NAME: github_actions run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" From 3c2e33beaa76910173b096781e56d4295d7657f0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 13:43:31 +0000 Subject: [PATCH 14/20] Prepare version 1.0.9-SNAPSHOT for development [skip ci] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b73439b..db97f3d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group "io.github.jamsesso" -version "1.0.8-SNAPSHOT" +version "1.0.9-SNAPSHOT" sourceCompatibility = 1.8 targetCompatibility = 1.8 From 59235ed2a10aeb13c691c0d5b12eb7dcfc83b521 Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:45:55 -0300 Subject: [PATCH 15/20] Prepare for merge --- .github/workflows/build.yml | 16 +++++++--------- build.gradle | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0fc0550..93af3e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,12 +33,11 @@ jobs: publish: needs: build - # TODO - # if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') runs-on: ubuntu-latest environment: production steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 8 uses: actions/setup-java@v3 with: @@ -52,11 +51,10 @@ jobs: with: name: build-artifacts path: build/ - # TODO - # - name: Set release version - # run: | - # # Remove -SNAPSHOT from version - # sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle + - name: Set release version + run: | + # Remove -SNAPSHOT from version + sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle - name: Publish package env: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} @@ -89,7 +87,7 @@ jobs: - name: Commit version bump env: NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} - BRANCH_NAME: github_actions + BRANCH_NAME: main run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" diff --git a/build.gradle b/build.gradle index db97f3d..b73439b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group "io.github.jamsesso" -version "1.0.9-SNAPSHOT" +version "1.0.8-SNAPSHOT" sourceCompatibility = 1.8 targetCompatibility = 1.8 From 0b38b48785167a38ebe576758195ed72a6d68bda Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:48:48 -0300 Subject: [PATCH 16/20] Remove .vscode folder --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e0f15db..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "automatic" -} \ No newline at end of file From 311c19b43e5811cf31f7951c8f9a49e32e6ac1fb Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:49:08 -0300 Subject: [PATCH 17/20] Add .vscode to the .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2398de1..71ffd03 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ out/ build/ .DS_Store -secring.gpg \ No newline at end of file +secring.gpg +.vscode \ No newline at end of file From d4a7bada06610f412215b3a74c4e7adef6863b4e Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:51:29 -0300 Subject: [PATCH 18/20] Split into multiple files --- .github/workflows/build.yml | 74 +---------------------------------- .github/workflows/publish.yml | 64 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93af3e7..fca139e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,6 @@ name: Build on: - push: - branches: [ main, master ] pull_request: branches: [ main, master ] @@ -24,74 +22,4 @@ jobs: cache-read-only: false gradle-home-cache-cleanup: true - name: Build - run: ./gradlew build - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: build/ - - publish: - needs: build - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') - runs-on: ubuntu-latest - environment: production - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - cache: 'gradle' - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts - path: build/ - - name: Set release version - run: | - # Remove -SNAPSHOT from version - sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle - - name: Publish package - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - run: | - ./gradlew uploadArchives - - name: Bump version - id: bump_version - run: | - # Get current version without SNAPSHOT - CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/') - - # Split into parts - IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" - - # Increment patch version - NEXT_PATCH=$((VERSION_PARTS[2] + 1)) - - # Create new version - NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT" - - # Update build.gradle - sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle - - # Make the new version available to other steps - echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT - - name: Commit version bump - env: - NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} - BRANCH_NAME: main - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add --all - git commit -m "Prepare version $NEXT_VERSION for development [skip ci]" - git pull --rebase origin $BRANCH_NAME - git push origin HEAD:$BRANCH_NAME \ No newline at end of file + run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d854e54 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,64 @@ +name: Publish + +on: + push: + branches: [ main, master, github_actions ] + +jobs: + publish: + runs-on: ubuntu-latest + environment: production + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + cache: 'gradle' + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Set release version + run: | + # Remove -SNAPSHOT from version + sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle + - name: Publish package + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + run: | + ./gradlew uploadArchives + - name: Bump version + id: bump_version + run: | + # Get current version without SNAPSHOT + CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/') + + # Split into parts + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + + # Increment patch version + NEXT_PATCH=$((VERSION_PARTS[2] + 1)) + + # Create new version + NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT" + + # Update build.gradle + sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle + + # Make the new version available to other steps + echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT + - name: Commit version bump + env: + NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }} + BRANCH_NAME: github_actions + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add --all + git commit -m "Prepare version $NEXT_VERSION for development [skip ci]" + git pull --rebase origin $BRANCH_NAME + git push origin HEAD:$BRANCH_NAME \ No newline at end of file From 386fd459cdda6903e8ca7e6fe12d916ab4fd0b0d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 13:54:15 +0000 Subject: [PATCH 19/20] Prepare version 1.0.9-SNAPSHOT for development [skip ci] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b73439b..db97f3d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group "io.github.jamsesso" -version "1.0.8-SNAPSHOT" +version "1.0.9-SNAPSHOT" sourceCompatibility = 1.8 targetCompatibility = 1.8 From 27ce019759fb20475a97a979a5289535c6ec4c8c Mon Sep 17 00:00:00 2001 From: Sam Jesso Date: Sat, 15 Mar 2025 10:59:22 -0300 Subject: [PATCH 20/20] Clean up TODOs --- .github/workflows/publish.yml | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d854e54..da07d48 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish on: push: - branches: [ main, master, github_actions ] + branches: [ main, master ] jobs: publish: @@ -30,7 +30,7 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} run: | - ./gradlew uploadArchives + ./gradlew build uploadArchives - name: Bump version id: bump_version run: | diff --git a/build.gradle b/build.gradle index db97f3d..b73439b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group "io.github.jamsesso" -version "1.0.9-SNAPSHOT" +version "1.0.8-SNAPSHOT" sourceCompatibility = 1.8 targetCompatibility = 1.8