Skip to content

Commit e37a29b

Browse files
committed
CI Test
Signed-off-by: Hendrix-Shen <HendrixShen@hendrixshen.top>
1 parent 02d41fa commit e37a29b

12 files changed

Lines changed: 883 additions & 229 deletions

.github/workflows/CI.yml

Lines changed: 159 additions & 229 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: step.build
2+
on:
3+
workflow_call:
4+
inputs:
5+
build_publish:
6+
type: string
7+
required: true
8+
build_version_type:
9+
type: string
10+
required: true
11+
target_subproject:
12+
description: see CI.yml, leave it empty to build all
13+
type: string
14+
required: false
15+
default: ''
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout the sources
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Set up JDK 21
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: 'temurin'
28+
java-version: 21
29+
- name: Cache gradle files
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/.gradle/caches
34+
~/.gradle/wrapper
35+
./.gradle/loom-cache
36+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle.properties', '**/*.accesswidener', 'settings.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-gradle-
39+
# TODO: Remove in next major version
40+
- name: Preprocess Resources
41+
run: |
42+
chmod +x gradlew
43+
./gradlew preprocessResources
44+
env:
45+
BUILD_TYPE: ${{ inputs.build_version_type }}
46+
- name: Build with gradle
47+
run: |
48+
chmod +x gradlew
49+
if [ -z "${{ inputs.target_subproject }}" ]; then
50+
echo "Building all subprojects"
51+
./gradlew build
52+
else
53+
args=$(echo "${{ inputs.target_subproject }}" | tr ',' '\n' | sed 's/$/:build/' | paste -sd ' ')
54+
echo "Building with arguments=$args"
55+
./gradlew $args
56+
fi
57+
env:
58+
BUILD_TYPE: ${{ inputs.build_version_type }}
59+
- name: Publish Maven with Gradle
60+
if: ${{ inputs.build_publish == 'true' }}
61+
run: |
62+
if [ -z "${{ inputs.target_subproject }}" ]; then
63+
echo "Publishing all subprojects"
64+
./gradlew publish
65+
else
66+
args=$(echo "${{ inputs.target_subproject }}" | tr ',' '\n' | sed 's/$/:publish/' | paste -sd ' ')
67+
echo "Publishing with arguments=$args"
68+
./gradlew $args
69+
fi
70+
env:
71+
BUILD_TYPE: ${{ inputs.build_version_type }}
72+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
73+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
74+
SIGNING_PGP_KEY: ${{ secrets.SIGNING_PGP_KEY }}
75+
- name: Upload artifacts
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: build-artifacts
79+
path: |
80+
*/**/build/libs/
81+
*/**/build/tmp/submods/
82+
summary:
83+
runs-on: ubuntu-22.04
84+
needs:
85+
- build
86+
steps:
87+
- name: Checkout the sources
88+
uses: actions/checkout@v4
89+
with:
90+
fetch-depth: 0
91+
- name: Download build artifacts
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: build-artifacts
95+
path: build-artifacts
96+
- name: Make build summary
97+
# ubuntu-22.04 uses Python 3.10.6
98+
run: python3 .github/workflows/scripts/summary.py
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: step.generate_matrix
2+
on:
3+
workflow_call:
4+
inputs:
5+
target_subproject:
6+
description: see CI.yml, for generating matrix entries
7+
type: string
8+
required: false
9+
default: ''
10+
outputs:
11+
matrix:
12+
description: The generated run matrix
13+
value: ${{ jobs.generate_matrix.outputs.matrix }}
14+
jobs:
15+
generate_matrix:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- name: Checkout the sources
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Generate matrix
23+
id: generate_matrix
24+
# ubuntu-22.04 uses Python 3.10.6
25+
run: python3 .github/workflows/scripts/matrix.py
26+
env:
27+
TARGET_SUBPROJECT: ${{ inputs.target_subproject }}
28+
outputs:
29+
matrix: ${{ steps.generate_matrix.outputs.matrix }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: step.generate_matrix_core
2+
on:
3+
workflow_call:
4+
inputs:
5+
target_subproject:
6+
description: see CI.yml, for generating matrix entries
7+
type: string
8+
required: false
9+
default: ''
10+
outputs:
11+
matrix:
12+
description: The generated run matrix
13+
value: ${{ jobs.generate_matrix.outputs.matrix }}
14+
jobs:
15+
generate_matrix:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- name: Checkout the sources
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Generate matrix
23+
id: generate_matrix
24+
# ubuntu-22.04 uses Python 3.10.6
25+
run: python3 .github/workflows/scripts/matrix_core.py
26+
env:
27+
TARGET_SUBPROJECT: ${{ inputs.target_subproject }}
28+
outputs:
29+
matrix: ${{ steps.generate_matrix.outputs.matrix }}

.github/workflows/publish.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: step.publish
2+
on:
3+
workflow_call:
4+
inputs:
5+
publish_channel:
6+
type: string
7+
required: true
8+
publish_mc_ver:
9+
type: string
10+
required: true
11+
publish_platform:
12+
type: string
13+
required: true
14+
publish_target_release_tag:
15+
description: |-
16+
The tag of the release you want to append the artifact to.
17+
type: string
18+
required: true
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
# Allow the mod publish step to add asserts to release
23+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
24+
permissions:
25+
contents: write
26+
steps:
27+
- name: Checkout the sources
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
- name: Download build artifacts
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: build-artifacts
35+
path: build-artifacts
36+
- name: Get git info
37+
id: get_git_info
38+
run: |
39+
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7)
40+
commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l)
41+
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
42+
echo "commit_count=$commit_count" >> $GITHUB_OUTPUT
43+
- name: Read Properties mod info
44+
id: mod_info
45+
uses: christian-draeger/read-properties@1.1.1
46+
with:
47+
path: gradle.properties
48+
properties: 'mod.name mod.version'
49+
- name: Publish Minecraft Mods (Dev Channel)
50+
if: ${{ inputs.publish_channel == 'dev' }}
51+
uses: Kir-Antipov/mc-publish@v3.3
52+
with:
53+
# modrinth-id:
54+
# modrinth-token: ${{ secrets.MODRINTH_API_TOKEN }}
55+
# curseforge-id:
56+
# curseforge-token: ${{ secrets.CF_API_TOKEN }}
57+
github-tag: ${{ github.ref_name }}.${{ steps.get_git_info.outputs.commit_count }}
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
59+
github-prerelease: true
60+
github-generate-changelog: true
61+
github-files: |
62+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar
63+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
64+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar
65+
files: |
66+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar
67+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
68+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
69+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar
70+
name: '[CI#${{ github.run_number }}]${{ steps.mod_info.outputs.mod-name }} ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}'
71+
version: ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}
72+
version-type: alpha
73+
changelog: |
74+
**This version is automatically released by CI Build**
75+
Latest commit log:
76+
${{ github.event.head_commit.message }}
77+
loaders: |
78+
${{ inputs.publish_platform }}
79+
game-versions: |
80+
${{ inputs.publish_mc_ver }}
81+
game-version-filter: any
82+
dependencies: |
83+
carpet(optional)
84+
malilib(optional)
85+
retry-attempts: 2
86+
retry-delay: 10000
87+
- name: Publish Minecraft Mods (Stable Channel)
88+
if: ${{ inputs.publish_channel == 'stable' }}
89+
uses: Kir-Antipov/mc-publish@v3.3
90+
with:
91+
# modrinth-id:
92+
# modrinth-token: ${{ secrets.MODRINTH_API_TOKEN }}
93+
# curseforge-id:
94+
# curseforge-token: ${{ secrets.CF_API_TOKEN }}
95+
github-tag: ${{ inputs.publish_target_release_tag }}
96+
github-token: ${{ secrets.GITHUB_TOKEN }}
97+
github-generate-changelog: true
98+
github-files: |
99+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar
100+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
101+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar
102+
files: |
103+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/libs/!(*-@(dev|sources|javadoc|empty)).jar
104+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
105+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
106+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/${{ inputs.publish_mc_ver }}/build/tmp/submods/unpublish/!(*-@(dev|sources|javadoc|empty)).jar
107+
name: '${{ steps.mod_info.outputs.mod-name }} ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}'
108+
version: ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}
109+
version-type: release
110+
changelog: ${{ github.event.release.body }}
111+
loaders: |
112+
${{ inputs.publish_platform }}
113+
game-versions: |
114+
${{ inputs.publish_mc_ver }}
115+
game-version-filter: any
116+
dependencies: |
117+
carpet(optional)
118+
malilib(optional)
119+
retry-attempts: 2
120+
retry-delay: 10000

.github/workflows/publish_core.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: step.publish_core
2+
on:
3+
workflow_call:
4+
inputs:
5+
publish_channel:
6+
type: string
7+
required: true
8+
publish_platform:
9+
type: string
10+
required: true
11+
publish_target_release_tag:
12+
description: |-
13+
The tag of the release you want to append the artifact to.
14+
type: string
15+
required: true
16+
jobs:
17+
publish:
18+
runs-on: ubuntu-latest
19+
# Allow the mod publish step to add asserts to release
20+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
21+
permissions:
22+
contents: write
23+
steps:
24+
- name: Checkout the sources
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
- name: Download build artifacts
29+
uses: actions/download-artifact@v4
30+
with:
31+
name: build-artifacts
32+
path: build-artifacts
33+
- name: Get git info
34+
id: get_git_info
35+
run: |
36+
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7)
37+
commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l)
38+
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
39+
echo "commit_count=$commit_count" >> $GITHUB_OUTPUT
40+
- name: Read Properties mod info
41+
id: mod_info
42+
uses: christian-draeger/read-properties@1.1.1
43+
with:
44+
path: gradle.properties
45+
properties: 'mod.name mod.version'
46+
- name: Publish Minecraft Mods (Dev Channel)
47+
if: ${{ inputs.publish_channel == 'dev' }}
48+
uses: Kir-Antipov/mc-publish@v3.3
49+
with:
50+
github-tag: ${{ github.ref_name }}.${{ steps.get_git_info.outputs.commit_count }}
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
github-prerelease: true
53+
github-generate-changelog: true
54+
files: |
55+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
56+
name: '[CI#${{ github.run_number }}]${{ steps.mod_info.outputs.mod-name }} ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}'
57+
version: ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}
58+
changelog: |
59+
**This version is automatically released by CI Build**
60+
Latest commit log:
61+
${{ github.event.head_commit.message }}
62+
- name: Publish Minecraft Fabric Mods (Stable Channel)
63+
if: ${{ inputs.publish_channel == 'stable' }}
64+
uses: Kir-Antipov/mc-publish@v3.3
65+
with:
66+
github-tag: ${{ inputs.publish_target_release_tag }}
67+
github-token: ${{ secrets.GITHUB_TOKEN }}
68+
files: |
69+
build-artifacts/magiclib-wrapper/${{ inputs.publish_platform }}/build/tmp/submods/publish/!(*-@(dev|sources|javadoc|empty)).jar
70+
name: '${{ steps.mod_info.outputs.mod-name }} ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}+${{ steps.get_git_info.outputs.short_sha }}'
71+
version: ${{ steps.mod_info.outputs.mod-version }}.${{ steps.get_git_info.outputs.commit_count }}
72+
retry-attempts: 2
73+
retry-delay: 10000

0 commit comments

Comments
 (0)