-
Notifications
You must be signed in to change notification settings - Fork 192
105 lines (91 loc) · 3.43 KB
/
release.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
name: Release GH+MR+CF
on:
workflow_dispatch:
inputs:
releaseType:
type: choice
description: Release Type
options:
- stable
- beta
- alpha
platform:
type: choice
description: Platform
options:
- both
- fabric
- neoforge
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
cache-read-only: true
- name: Validate Gradle Wrapper Integrity
uses: gradle/actions/wrapper-validation@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle Release Build
env:
RELEASE_WORKFLOW: true
PLATFORM: ${{ inputs.platform }}
run: ./gradlew build
- name: Set environment variables for the script below
run: |
echo "MINECRAFT_VERSION=$(./gradlew -q printMinecraftVersion)" >> $GITHUB_ENV
echo "MOD_VERSION=$(./gradlew -q printModVersion)" >> $GITHUB_ENV
- name: Set Release Name
id: set_release_name
run: |
if [ "${{ inputs.platform }}" == "both" ]; then
echo "RELEASE_NAME=Lithium $MOD_VERSION for Minecraft $MINECRAFT_VERSION Fabric and Neoforge" >> $GITHUB_ENV
elif [ "${{ inputs.platform }}" == "fabric" ]; then
echo "RELEASE_NAME=Lithium $MOD_VERSION for Minecraft $MINECRAFT_VERSION Fabric" >> $GITHUB_ENV
elif [ "${{ inputs.platform }}" == "neoforge" ]; then
echo "RELEASE_NAME=Lithium $MOD_VERSION for Minecraft $MINECRAFT_VERSION Neoforge" >> $GITHUB_ENV
fi
- name: Replace placeholders in CHANGELOG.md
run: |
sed -i 's/_ReleaseTag_/mc${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}/g' CHANGELOG.md
sed -i 's/_MCVersion_/${{ env.MINECRAFT_VERSION }}/g' CHANGELOG.md
sed -i 's/_LithiumVersion_/${{ env.MOD_VERSION }}/g' CHANGELOG.md
- name: Trim CHANGELOG.md
run: |
trimmed_changelog=$(awk '/----------/{flag=1;next}flag' CHANGELOG.md)
echo "$trimmed_changelog" > CHANGELOG.md
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: mc${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}
release_name: ${{ env.RELEASE_NAME }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ inputs.releaseType != 'stable' }}
- name: Upload assets to GitHub
uses: AButler/[email protected]
with:
files: 'build/libs/*.jar;!build/libs/*-dev.jar;LICENSE'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-id: ${{ steps.create_release.outputs.id }}
- name: Publish to Modrinth and Curseforge
env:
RELEASE_WORKFLOW: true
RELEASE_TYPE: ${{ inputs.releaseType }}
PLATFORM: ${{ inputs.platform }}
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
run: ./gradlew lithiumPublish