Skip to content

Commit

Permalink
Use GitHub actions for build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Jan 18, 2021
1 parent 91566f1 commit 2fe375f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
release:
types:
- published

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and publish with Gradle
run: ./gradlew build publish
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
with:
files: 'build/libs/*.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id 'maven-publish'
}

def env = System.getenv()

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

Expand Down Expand Up @@ -69,13 +71,13 @@ publishing {
}

repositories {
if (project.hasProperty("mavenUrl")) {
if (env.MAVEN_URL) {
maven {
credentials {
username project.mavenUsername ?: ""
password project.mavenPassword ?: ""
username env.MAVEN_USERNAME
password env.MAVEN_PASSWORD
}
url project.mavenUrl ?: ""
url env.MAVEN_URL
}
} else {
mavenLocal()
Expand Down

0 comments on commit 2fe375f

Please sign in to comment.