Skip to content

Commit 7f44446

Browse files
committed
Add a workflow to build tagged releases
1 parent 67ae254 commit 7f44446

File tree

3 files changed

+54
-156
lines changed

3 files changed

+54
-156
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 154 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Tagged Release Version
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up JDK 8
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '8'
19+
distribution: 'temurin'
20+
- name: Validate Gradle wrapper
21+
uses: gradle/wrapper-validation-action@v1
22+
- uses: actions/cache@v4
23+
with:
24+
path: |
25+
~/.gradle/caches
26+
~/.gradle/wrapper
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
28+
restore-keys: ${{ runner.os }}-gradle-
29+
- name: Build with Gradle
30+
run: ./gradlew build -Prelease_tag="${{ github.ref_name }}"
31+
- name: Archive artifacts
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: OpenComputers
35+
path: build/libs/*.jar

build.gradle

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,25 @@ file "build.properties" withReader {
2121
prop.load(it)
2222
ext.config = new ConfigSlurper().parse prop
2323
}
24-
if (!project.hasProperty("mod_version")) {
25-
project.ext.mod_version = config.mod.version
24+
if (project.hasProperty("release_tag")) {
25+
def rtag = project.getProperty("release_tag");
26+
def verIdx = rtag.indexOf("/");
27+
if (verIdx <= 0 || verIdx >= rtag.length() - 1) throw new Error("malformed release tag " + rtag);
28+
def baseVer = rtag.substring(0, verIdx);
29+
def ldrIdx = baseVer.indexOf("-");
30+
if (ldrIdx <= 0 || ldrIdx >= baseVer.length() - 1) throw new Error("malformed base version " + baseVer);
31+
if (baseVer.substring(0, ldrIdx) != config.minecraft.version)
32+
{
33+
throw new Error("incorrect minecraft version " + baseVer.substring(0, ldrIdx) + ", expected " + config.minecraft.version);
34+
}
35+
if (baseVer.substring(ldrIdx + 1) != "forge")
36+
{
37+
throw new Error("incorrect mod loader " + baseVer.substring(ldrIdx + 1) + ", expected forge");
38+
}
39+
ext.mod_version = rtag.substring(verIdx + 1);
40+
}
41+
else if (!project.hasProperty("mod_version")) {
42+
ext.mod_version = config.mod.version
2643
}
2744

2845
version = "${mod_version}"

0 commit comments

Comments
 (0)