Skip to content

Commit

Permalink
refactor(build): streamline gradle properties and workflow configs
Browse files Browse the repository at this point in the history
Refactor the gradle.properties file to introduce the mod id, name, and version labelsfor better project versioning control. Adjust the CI workflow configurations to use thesenew labels, ensuring consistency across the project. Additionally, update the fabric.mod.json
to reference the new mod version variable. These changes aim to standardize version management
and simplify future updates.
  • Loading branch information
cnlimiter committed Aug 13, 2024
1 parent 335ad20 commit 83fe0c2
Show file tree
Hide file tree
Showing 85 changed files with 654 additions and 506 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/action.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Build PR'

on:
pull_request:
types:
- synchronize
- opened
- ready_for_review
- reopened

push:
branches:
- '*/**'

workflow_dispatch:

jobs:
build:
name: 'Build PR'
runs-on: ubuntu-latest
strategy:
matrix:
loader: [ 'Forge', 'Fabric' ]

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 100
fetch-tags: true

- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 'Build ${{ matrix.loader }} with Gradle'
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ matrix.loader }}:build
cache-read-only: false

- name: 'Upload ${{ matrix.loader }} artifacts'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: 'Artifacts-${{ matrix.loader }}'
path: ${{ matrix.loader }}/build/libs/*.jar
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 'Build'

on:
workflow_call:
push:
branches:
- 'multi/*'

permissions:
contents: read
statuses: write

jobs:
build:
name: 'Build'
runs-on: ubuntu-latest
strategy:
matrix:
loader: [ 'Forge', 'Fabric' ]

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 100
fetch-tags: true

- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 'Build ${{ matrix.loader }} with Gradle'
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ matrix.loader }}:build
cache-read-only: false

- name: 'Upload ${{ matrix.loader }} artifacts'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: 'Artifacts-${{ matrix.loader }}'
path: ${{ matrix.loader }}/build/libs/*.jar
120 changes: 120 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: 'Publish'

on:
workflow_dispatch:
inputs:
label:
type: choice
description: 'Version label'
options:
- -beta
- -alpha
default: ''
required: false

permissions:
contents: write
statuses: write

jobs:
build:
name: 'Build'
runs-on: ubuntu-latest
strategy:
matrix:
loader: [ 'Forge', 'Fabric' ]

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 100
fetch-tags: true

- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 'Build ${{ matrix.loader }} with Gradle'
uses: gradle/gradle-build-action@v2
with:
arguments: :${{ matrix.loader }}:build
cache-read-only: false

- name: 'Upload ${{ matrix.loader }} artifacts'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: 'Artifacts-${{ matrix.loader }}'
path: ${{ matrix.loader }}/build/libs/*.jar

publish:
name: 'Publish'
runs-on: ubuntu-latest

needs: [build]

continue-on-error: true

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 100
fetch-tags: true

- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 'Publish with Gradle'
uses: gradle/gradle-build-action@v2
with:
arguments: publishMod
cache-read-only: false
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

release:
name: 'Create release'
runs-on: ubuntu-latest

needs: [build, publish]

continue-on-error: true

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 100
fetch-tags: true

- name: 'Get latest tag'
id: latest-tag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: '0.0.0.0'

- name: 'Download ${{ matrix.loader }} artifacts'
uses: actions/download-artifact@v4
with:
pattern: 'Artifacts-*'
path: artifacts/
merge-multiple: true

- name: 'Create release'
uses: softprops/action-gh-release@v1
with:
name: "${{ github.event.repository.name }}-${{ github.ref_name }}-${{ steps.latest-tag.outputs.tag }}${{ inputs.label }}"
tag_name: ${{ steps.latest-tag.outputs.tag }}
target_commitish: ${{ github.ref }}
body_path: CHANGELOG.md
files: |
'artifacts/*'
'!artifacts/*-slim.*'
49 changes: 0 additions & 49 deletions .github/workflows/release.yml

This file was deleted.

29 changes: 29 additions & 0 deletions Common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apply plugin: 'org.spongepowered.gradle.vanilla'

println "Using Minecraft: $minecraft_version"

minecraft {
version minecraft_version
if(file("src/main/resources/${mod_id}.accesswidener").exists()) {
accessWideners file("src/main/resources/${mod_id}.accesswidener")
}
}

repositories {
mavenCentral() {
content {
includeGroup 'org.projectlombok'
}
}
maven { url 'https://maven.nova-committee.cn/releases' }
}

dependencies {
implementation ("org.spongepowered:mixin:0.8.5")
compileOnly ("org.projectlombok:lombok:$lombok_version")
annotationProcessor ("org.projectlombok:lombok:$lombok_version")
implementation ("cn.evole.onebot:OneBot-Client:$onebot_client_version"){transitive = false}
implementation ("org.spongepowered:configurate-yaml:$yaml_version")
implementation("com.github.houbb:csv:0.2.0")
implementation ("com.google.code.findbugs:jsr305:3.0.1")
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 83fe0c2

Please sign in to comment.