-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (128 loc) · 4.72 KB
/
pipeline.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Build and Release Mod
on:
push:
branches:
- '**'
create:
tags:
- '*'
permissions:
contents: write
checks: write
jobs:
test:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run unit tests
run: ./gradlew test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: build/test-results/test
- name: Upload test report
if: always()
uses: mikepenz/action-junit-report@v3
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
release:
runs-on: ubuntu-latest
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run unit tests
run: ./gradlew test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: build/test-results/test
- name: Upload test report
if: always()
uses: mikepenz/action-junit-report@v3
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Build project
run: ./gradlew build
- name: Extract properties from gradle.properties
id: properties
run: |
modId=$(grep 'modId' gradle.properties | cut -d'=' -f2 | xargs)
modVersion=$(grep 'modVersion' gradle.properties | cut -d'=' -f2 | xargs)
minecraftFirstSnapshotVersion=$(grep 'minecraftFirstSnapshotVersion' gradle.properties | cut -d'=' -f2 | xargs)
minecraftReleaseVersion=$(grep 'minecraftReleaseVersion' gradle.properties | cut -d'=' -f2 | xargs)
fabricSupportedLoaders=$(grep 'fabricSupportedLoaders' gradle.properties | cut -d'=' -f2 | xargs)
echo "MOD_ID=$modId" >> $GITHUB_ENV
echo "MOD_VERSION=$minecraftReleaseVersion-$modVersion" >> $GITHUB_ENV
echo "MINECRAFT_VERSIONS=Minecraft: $minecraftFirstSnapshotVersion-$minecraftReleaseVersion" >> $GITHUB_ENV
echo "LOADERS=Loaders: $fabricSupportedLoaders" >> $GITHUB_ENV
echo "MINECRAFT_FIRST_SNAPSHOT_VERSION=$minecraftFirstSnapshotVersion" >> $GITHUB_ENV
echo "MINECRAFT_RELEASE_VERSION=$minecraftReleaseVersion" >> $GITHUB_ENV
- name: Get version changelog
id: changelog
run: |
VERSION=${{ env.MOD_VERSION }}
CHANGELOG=$(sed -n "/^## $VERSION$/,/^## [0-9]/p" CHANGELOG.md | sed '$d' | tail -n +2)
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
- name: Combine release notes
id: combine
run: |
echo "${{ env.MINECRAFT_VERSIONS }}" > combined_changelog.txt
echo "${{ env.LOADERS }}" >> combined_changelog.txt
echo "" >> combined_changelog.txt
echo "## Changes" >> combined_changelog.txt
echo "" >> combined_changelog.txt
echo "${{ env.CHANGELOG }}" >> combined_changelog.txt
cat combined_changelog.txt
echo "FINAL_CHANGELOG<<EOF" >> $GITHUB_ENV
cat combined_changelog.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: "Foggy Pale Garden ${{ env.MOD_VERSION }}"
files: build/libs/*.jar
body: ${{ env.FINAL_CHANGELOG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Modrinth
run: ./gradlew modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
- name: Publish to CurseForge
run: ./gradlew curseforge
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}