Skip to content

Commit a2fd406

Browse files
committed
setup ci/cd
1 parent a37d74b commit a2fd406

7 files changed

Lines changed: 107 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "publish"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "master"
8+
paths:
9+
- src/**
10+
- build.gradle
11+
- gradle.properties
12+
- settings.gradle
13+
workflow_dispatch:
14+
15+
env:
16+
RELEASE_TITLE: "Anchiale build ${{github.run_number}}"
17+
RELEASE_NUMBER: "${{github.run_number}}"
18+
RELEASE_FILE: "build/libs/*${{github.run_number}}.0.0.jar"
19+
20+
jobs:
21+
publish:
22+
runs-on: "ubuntu-latest"
23+
steps:
24+
- name: Checkout sources
25+
uses: actions/checkout@v2
26+
- name: Set up JDK 17
27+
uses: actions/setup-java@v1
28+
with:
29+
java-version: 17
30+
- name: Build artifacts
31+
run: ./gradlew build
32+
- name: Publish tagged version
33+
uses: "marvinpinto/action-automatic-releases@latest"
34+
with:
35+
automatic_release_tag: "v${{ env.RELEASE_NUMBER }}"
36+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
37+
prerelease: false
38+
title: ${{ env.RELEASE_TITLE }}
39+
files: |
40+
LICENSE*
41+
${{ env.RELEASE_FILE }}
42+
- name: Publish latest
43+
uses: "marvinpinto/action-automatic-releases@latest"
44+
with:
45+
automatic_release_tag: "latest"
46+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
47+
prerelease: false
48+
title: ${{ env.RELEASE_TITLE }}
49+
files: |
50+
LICENSE*
51+
${{ env.RELEASE_FILE }}

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "test"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "main"
7+
- "master"
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: "ubuntu-latest"
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@v2
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v1
18+
with:
19+
java-version: 17
20+
- name: Build artifacts
21+
run: ./gradlew build

build.gradle

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
plugins {
22
id 'fabric-loom' version "0.7-SNAPSHOT" // To use chocoloom, change the version to a commit hash
33
id 'maven-publish'
4+
id 'org.ajoberstar.grgit' version '4.1.0'
45
}
56

67
sourceCompatibility = JavaVersion.VERSION_1_8
78
targetCompatibility = JavaVersion.VERSION_1_8
89

9-
archivesBaseName = project.archives_base_name
10-
version = "${project.mod_version}+${project.minecraft_version}" as Object
10+
def getVersionMetadata() {
11+
// CI builds version numbers
12+
def build_id = System.getenv("RELEASE_NUMBER")
13+
if (build_id != null) {
14+
return build_id + ".0.0"
15+
}
16+
17+
// Development builds
18+
if (grgit == null) {
19+
return "dev"
20+
}
21+
22+
// Named development builds
23+
def id = grgit.head().abbreviatedId
24+
if (!grgit.status().clean) {
25+
id += "-dirty"
26+
}
27+
28+
return "rev.${id}"
29+
}
30+
31+
archivesBaseName = "${project.mod_id}-${project.minecraft_version}"
32+
version = "${getVersionMetadata()}"
1133
group = project.maven_group
1234

1335
repositories {
@@ -58,10 +80,11 @@ if (System.getProperty("os.name").toLowerCase().contains("mac")) {
5880
}
5981

6082
processResources {
83+
inputs.property "mod_id", project.mod_id
6184
inputs.property "version", project.version
6285

6386
filesMatching("fabric.mod.json") {
64-
expand "version": project.version
87+
expand "mod_id": project.mod_id, "version": project.version
6588
}
6689
}
6790

docs/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
## Description
3+
- Provide a brief overview of your changes
4+
- Call out any interesting implementation details describing _why_ you made specific decisions
5+
6+
Checklist
7+
- [ ] Build compiles and is ready to be automatically be released to the public

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ loader_version = 0.12.12
1010
# Mod Properties
1111
mod_version = 1.0.2
1212
maven_group = me.voidxwalker
13-
archives_base_name = anchiale
13+
mod_id = anchiale

gradlew

100644100755
File mode changed.

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schemaVersion": 1,
3-
"id": "anchiale",
3+
"id": "${mod_id}",
44
"version": "${version}",
55
"name": "Anchiale",
66
"description": "",

0 commit comments

Comments
 (0)