Skip to content

Commit

Permalink
Infer archive name from release tag
Browse files Browse the repository at this point in the history
  • Loading branch information
PhiProven committed Oct 3, 2021
1 parent 37fb45a commit 2e67611
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ jobs:
with:
distribution: 'adopt'
java-version: 16
- name: Set release tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Build with Gradle
run: ./gradlew build
env:
BUILD_ID: ${{ github.run_number }}
- name: Upload build artifacts
uses: actions/upload-artifact@v1
with:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: release-artifacts

on:
release:
types:
- published
types: [published]

jobs:
build:
Expand All @@ -16,6 +15,12 @@ jobs:
with:
distribution: 'adopt'
java-version: 16
- name: Set release tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Set build id
if: github.event.release.prerelease
run: echo "BUILD_ID=SNAPSHOT" >> $GITHUB_ENV
- name: Build with Gradle
run: ./gradlew build
- name: Upload assets to GitHub
Expand Down
17 changes: 9 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ plugins {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = "${project.archives_base_name}-mc${project.minecraft_version}"
archivesBaseName = project.archives_base_name
group = project.maven_group

def build_id = System.getenv("GITHUB_RUN_NUMBER");
def release_tag = System.getenv("RELEASE_TAG")
def build_id = System.getenv("BUILD_ID")

if (build_id == null) {
version = "${project.mod_version}-SNAPSHOT"
} else {
version = "${project.mod_version}+build.${build_id}"
version = release_tag == null ? "mc${project.minecraft_version}-${project.mod_version}" : release_tag

if (build_id != null) {
version += build_id == 'SNAPSHOT' ? '-SNAPSHOT' : "+build.${build_id}"
}

loom {
Expand All @@ -32,10 +33,10 @@ dependencies {
}

processResources {
inputs.property "version", project.version
inputs.property "version", project.mod_version

filesMatching("fabric.mod.json") {
expand "version": project.version
expand "version": project.mod_version
}
}

Expand Down

0 comments on commit 2e67611

Please sign in to comment.