Skip to content

Commit

Permalink
Merge pull request #2 from prantogg/add-github-action-build-jar
Browse files Browse the repository at this point in the history
Add GitHub action to build jars
  • Loading branch information
jiayuasu committed Jul 8, 2024
2 parents ee16d5b + 769d67f commit eda8a7e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Upload JAR

on:
push:
branches:
- main
paths:
- 'src/**'
- 'build.gradle'
- '.github/workflows/main.yml'
pull_request:
branches:
- '*'
paths:
- 'src/**'
- 'build.gradle'
- '.github/workflows/main.yml'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Verify Gradle installation
run: ./gradlew --version

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run build
run: chmod +x ./gradlew && ./gradlew build shadowJar
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
DO_NOT_TRACK: true

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: lib/build/libs/wherobots-jdbc-*.jar
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
4 changes: 4 additions & 0 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ tasks.named('jar') {
'Implementation-Version': project.version)
}
}

tasks.withType(Jar) {
archiveBaseName.set('wherobots-jdbc')
}

0 comments on commit eda8a7e

Please sign in to comment.