Update github workflows

- Add release workflow
- Add build numbers on action
This commit is contained in:
tibs 2022-01-17 16:20:25 -05:00
parent 38dd1d6ae7
commit 3c13e63e40
Signed by untrusted user who does not match committer: tibs
GPG key ID: 047833989F50F88F
3 changed files with 55 additions and 2 deletions

View file

@ -1,4 +1,4 @@
name: gradle-ci name: build-gradle
on: [ push, pull_request ] on: [ push, pull_request ]

27
.github/workflows/build-release.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: build-release
on:
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
- name: Build with Gradle
run: ./gradlew build
- name: Upload build artifacts
uses: AButler/upload-release-assets@v2.0
with:
files: 'build/libs/!(*-@(dev|sources)).jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,12 +1,14 @@
plugins { plugins {
id 'fabric-loom' version '0.10.+' id 'fabric-loom' version '0.10.+'
id 'io.github.juuxel.loom-quiltflower-mini' version '1.2.1' id 'io.github.juuxel.loom-quiltflower-mini' version '1.2.1'
id 'org.ajoberstar.grgit' version '4.1.0'
} }
sourceCompatibility = '17' sourceCompatibility = '17'
targetCompatibility = '17' targetCompatibility = '17'
version = project.mod_version archivesBaseName = project.archives_base_name
version = "${project.mod_version}${getVersionMetadata()}"
group = project.maven_group group = project.maven_group
repositories { repositories {
@ -65,3 +67,27 @@ jar {
rename { "${it}_${project.archivesBaseName}"} rename { "${it}_${project.archivesBaseName}"}
} }
} }
def getVersionMetadata() {
def build_id = System.getenv("GITHUB_RUN_NUMBER")
def workflow_id = System.getenv("GITHUB_WORKFLOW")
// CI builds only
if (workflow_id == "build-release") {
return "+${project.minecraft_version}"
} else if (build_id != null) {
return "+build.${build_id}"
}
if (grgit != null) {
def head = grgit.head()
def id = head.abbreviatedId
// Flag the build if the build tree is not clean
if (!grgit.status().clean) {
id += "-dirty"
}
return "+rev.${id}"
}
}