generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 23
130 lines (118 loc) · 4.44 KB
/
build-and-publish-pre-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
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
name: Build Pre-Release version and Publish
on:
workflow_dispatch:
inputs:
release-beta:
description: 'Publish a beta release?'
required: true
type: boolean
push:
branches:
- "1.21"
jobs:
build-and-publish-pre-release:
strategy:
matrix:
# Use thses Java versions:
java: [ 21 ] # Current Java LTS and current latest Java version
# Use these operating systems:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Store all lowercase commit message
run: |
echo COMMIT_MESSAGE=$( git log --format=%B --no-merges -n 1 | tr '[:upper:]' '[:lower:]' ) >> ${GITHUB_ENV}
echo COMMIT_MESSAGE_ALL=$( git log --format=%B --no-merges -n 1 ) >> ${GITHUB_ENV}
- name: Detect if a beta release should be published
if: ${{ contains(env.COMMIT_MESSAGE, '[publish beta]') || inputs.release-beta }}
run: |
echo "PUBLISH_BETA=true" >> ${GITHUB_ENV}
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Show Java version
run: java -version
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Show Gradle version
run: gradle --version
- name: Build with Gradle (DEV)
if : ${{ env.PUBLISH_BETA != 'true' }}
run: gradle getVersion build --stacktrace
- name: Build with Gradle (BETA)
if : ${{ env.PUBLISH_BETA == 'true' }}
env:
REDEN_BUILD_TYPE: "BETA"
run: gradle getVersion build --stacktrace
- name: Get Mod Name
id: get_mod_name
uses: christian-draeger/read-properties@1.1.1
with:
path: gradle.properties
properties: 'mod_name'
- name: Get Mod Version
id: get_mod_version
run: |
echo "mod_version=$(cat build/.reden-version)" >> $GITHUB_OUTPUT
echo "short_mod_version=$(cat build/.reden-short-version)" >> $GITHUB_OUTPUT
- name: Upload assets to GitHub Action
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: "[DEV-CI#${{ github.run_number }}] ${{ steps.get_mod_name.outputs.mod_name }} ${{ steps.get_mod_version.outputs.mod_version }} - Java ${{ matrix.java }}"
path: |
build/libs/*.jar
build/reports/tests/
- name: Publish to GitHub Pre-Releases
if: ${{ env.PUBLISH_BETA == 'true' && matrix.java == 21 }} # Only publish the version built with Java LTS
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: build/libs/*.jar
generateReleaseNotes: true
name: "[CI#${{ github.run_number }}] ${{ steps.get_mod_name.outputs.mod_name }} Mod Pre-Release ${{ steps.get_mod_version.outputs.mod_version }}"
prerelease: true
tag: "beta/${{ steps.get_mod_version.outputs.mod_version }}"
- name: Publish to Modrinth & CurseForge
if: ${{ env.PUBLISH_BETA == 'true' && matrix.java == 17 }} # Only publish the version built with Java LTS
uses: Kir-Antipov/mc-publish@v3.3
with:
# Publish to Modrinth
modrinth-id: xRu8OXEJ
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
# Publish to CurseForge
curseforge-id: 903236
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
# Universal Configurations
files: |
build/libs/*-@(beta).jar
build/libs/*-@(beta)*@(ci)*[0123456789].jar
name: "${{ steps.get_mod_name.outputs.mod_name }} Pre-Release ${{ steps.get_mod_version.outputs.mod_version }}"
version: "${{ steps.get_mod_version.outputs.short_mod_version }}"
version-type: beta
loaders: |
fabric
quilt
modrinth-featured: false
dependencies: |
carpet
malilib
fabric-api
fabric-language-kotlin
owo-lib
java: |
17
18
19
20
21
retry-attempts: 2
retry-delay: 10000
changelog: ${{ env.COMMIT_MESSAGE_ALL }}