Skip to content

Commit 8c93e11

Browse files
committed
Simplify build scripts and set up maven.hexxy.media publishing
1 parent 475f411 commit 8c93e11

File tree

5 files changed

+79
-35
lines changed

5 files changed

+79
-35
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ jobs:
77
matrix:
88
java: [ 17 ]
99
runs-on: ubuntu-latest
10-
env:
11-
PUBLISH_SUFFIX: snapshots
12-
MAVEN_USER: ${{ secrets.MAVEN_USER }}
13-
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
1410
steps:
1511

1612
- name: checkout repository
@@ -34,7 +30,7 @@ jobs:
3430
run: chmod +x ./gradlew
3531

3632
- name: build
37-
run: ./gradlew buildOrPublish
33+
run: ./gradlew build
3834

3935
- name: capture build artifacts
4036
uses: actions/upload-artifact@v2

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publish_maven:
7+
description: Publish to Maven
8+
type: boolean
9+
default: true
10+
dry_run:
11+
description: Perform a dry run
12+
type: boolean
13+
default: false
14+
15+
jobs:
16+
publish-maven:
17+
if: inputs.publish_maven
18+
runs-on: ubuntu-latest
19+
environment:
20+
name: ${{ !inputs.dry_run && 'maven' || '' }}
21+
permissions:
22+
contents: read
23+
id-token: write
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-java@v4
28+
with:
29+
distribution: temurin
30+
java-version: 17
31+
32+
- uses: gradle/actions/setup-gradle@v4
33+
34+
- name: Build mod
35+
run: ./gradlew build
36+
37+
- name: Login to Azure
38+
if: inputs.dry_run == false
39+
uses: azure/login@v2
40+
with:
41+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
42+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
43+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
44+
45+
- name: Get Azure access token
46+
id: get-token
47+
if: inputs.dry_run == false
48+
run: |
49+
token=$(az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 --output tsv)
50+
echo "::add-mask::$token"
51+
echo "token=$token" >> "$GITHUB_OUTPUT"
52+
53+
- name: Publish to ${{ inputs.dry_run && 'Maven Local' || 'Maven' }}
54+
env:
55+
MAVEN_PASSWORD: ${{ steps.get-token.outputs.token }}
56+
run: ./gradlew ${{ inputs.dry_run && 'publishToMavenLocal' || 'publish' }}
57+
58+
- name: Upload dry run artifact
59+
if: inputs.dry_run
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: maven-dry-run
63+
path: ~/.m2/repository/io/github/tropheusj
64+
if-no-files-found: error

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
#### Adds more hooks for Serialization of things.
33
Currently, Ingredients and Values are supported.
44

5+
Forked, updated to 1.20.1, and re-published by Falling Colors for use in Hex Casting.
6+
57
# Use
68
### Setup
79
```groovy
8-
maven { url = "https://mvn.devos.one/snapshots/" }
10+
maven { url = "https://maven.hexxy.media" }
911
```
1012
```groovy
11-
modImplementation(include("io.github.tropheusj:serialization-hooks:0.3.<build>"))
13+
modImplementation(include("io.github.tropheusj:serialization-hooks:0.4.99999"))
1214
```
13-
find the latest build from [GitHub Actions](https://github.com/TropheusJ/serialization-hooks/actions).
1415

1516
### Actually using it
1617
#### Ingredients

build.gradle

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ targetCompatibility = JavaVersion.VERSION_17
1212

1313
archivesBaseName = project.archives_base_name
1414
group = project.maven_group
15-
16-
ext.buildNumber = System.getenv("GITHUB_RUN_NUMBER")
17-
String patch = buildNumber != null ? buildNumber : "99999"
18-
version = project.mod_version.replace("<build>", patch)
15+
version = project.mod_version
1916

2017
repositories {
2118
maven { url = "https://maven.quiltmc.org/repository/release" }
@@ -77,18 +74,6 @@ loom {
7774
}
7875
}
7976

80-
task buildOrPublish {
81-
group = "build"
82-
String mavenUser = System.getenv().MAVEN_USER
83-
if (mavenUser != null && !mavenUser.isEmpty()) {
84-
dependsOn(tasks.getByName("publish"))
85-
println("prepared for publish")
86-
} else {
87-
dependsOn(tasks.getByName("build"))
88-
println("prepared for build")
89-
}
90-
}
91-
9277
processResources {
9378
Map<String, String> properties = new HashMap<>()
9479
properties.put("version", project.version)
@@ -126,13 +111,12 @@ publishing {
126111
}
127112

128113
repositories {
129-
maven {
130-
url = "https://mvn.devos.one/${System.getenv().PUBLISH_SUFFIX}/"
131-
credentials {
132-
username = System.getenv().MAVEN_USER
133-
password = System.getenv().MAVEN_PASS
134-
}
135-
authentication { basic(BasicAuthentication) }
136-
}
137-
}
114+
maven {
115+
url = "https://pkgs.dev.azure.com/hexxy-media/artifacts/_packaging/community/maven/v1"
116+
credentials {
117+
username = "hexxy-media"
118+
password = System.getenv("MAVEN_PASSWORD")
119+
}
120+
}
121+
}
138122
}

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ org.gradle.jvmargs=-Xmx2G
22

33
maven_group = io.github.tropheusj
44
archives_base_name = serialization_hooks
5-
# <build> is replaced at compile time with either GitHub Actions build number, or 99999 if not available.
6-
mod_version = 0.4.<build>
5+
mod_version = 0.4.99999
76

87
# https://fabricmc.net/develop
98
minecraft_version = 1.20.1

0 commit comments

Comments
 (0)