forked from P3pp3rF1y/SophisticatedCore
-
Notifications
You must be signed in to change notification settings - Fork 4
71 lines (71 loc) · 2.5 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Build
on: [ workflow_dispatch, push ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 200
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: zulu
cache: gradle
- name: Loom Cache
uses: actions/cache@v4
with:
path: "**/.gradle/loom-cache"
key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}"
restore-keys: "${{ runner.os }}-gradle-"
- uses: gradle/actions/wrapper-validation@v4
- run: chmod +x ./gradlew
- name: Build with Gradle
env:
USERNAME: ${{ secrets.USERNAME }}
READ_PACKAGES_TOKEN: ${{ secrets.READ_PACKAGES_TOKEN }}
run: ./gradlew build
- name: Read minecraft version from gradle.properties
id: read-version
run: |
minecraft_version=$(grep '^minecraft_version=' gradle.properties | cut -d'=' -f2)
echo "minecraft_version=$minecraft_version" >> $GITHUB_ENV
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: SophisticatedCore-${{ env.minecraft_version }}
path: build/libs
- name: Publish to Github Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publish
- name: Cleanup old artifacts
uses: actions/delete-package-versions@v5
with:
package-name: 'sophisticatedcore.sophisticatedcore'
package-type: 'maven'
min-versions-to-keep: 10
- name: Publish to CurseForge
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)-fabric$ ]]; then
./gradlew curseforge
else
echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping CurseForge upload."
exit 0
fi
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)-fabric$ ]]; then
./gradlew modrinth
else
echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping Modrinth upload."
exit 0
fi