-
Notifications
You must be signed in to change notification settings - Fork 8
165 lines (151 loc) · 5.45 KB
/
release.yml
File metadata and controls
165 lines (151 loc) · 5.45 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Builds the project and publishes the artifacts to GitHub, Modrinth and CurseForge.
# Modrinth publishing requires a Modrinth PAT `MODRINTH_TOKEN`
# Will skip without error if not present.
# CurseForge publishing requires a CurseForge API token `CURSEFORGE_TOKEN`
# Will skip without error if not present.
# Release version and other properties are set via the root `gradle.properties` file.
name: Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
fabric:
type: boolean
description: Publish Fabric Version
required: true
default: true
neoforge:
type: boolean
description: Publish NeoForge Version
required: true
default: true
github:
type: boolean
description: Publish to GitHub
required: true
default: true
modrinth:
type: boolean
description: Publish to Modrinth
required: true
default: true
curseforge:
type: boolean
description: Publish to CurseForge
required: true
default: true
syncModrinthDescription:
type: boolean
description: Sync Modrinth Description with README.md
required: true
default: false
java:
type: choice
description: Java Version
required: true
options:
- '25'
- '21'
- '17'
default: '25'
os:
type: choice
description: Operating System
required: true
options:
- 'ubuntu-latest'
- 'windows-latest'
default: 'ubuntu-latest'
jobs:
release:
runs-on: ${{ inputs.os }}
steps:
# Log the workflow input values for future reference.
- name: Log workflow inputs
run: |
echo '${{ toJson(inputs) }}' | jq .
# Retrieve and store the current Git branch name for future use.
- name: Extract branch name
id: ref
shell: bash
# bash pattern expansion to grab branch name without slashes
run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT
# Checkout the repository under $GITHUB_WORKSPACE, so the workflow can access it.
# https://github.com/actions/checkout
- name: Checkout sources
uses: actions/checkout@v6
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# Default: 1
fetch-depth: 0
# Setup Java for the build.
# https://github.com/actions/setup-java
- name: Setup JDK ${{ inputs.java }}
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: ${{ inputs.java }}
# Setup Gradle for the build.
# https://github.com/gradle/actions/blob/main/setup-gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Make Gradle wrapper executable
if: runner.os != 'Windows'
run: chmod +x ./gradlew
# Build the project; subsequent publish tasks will reuse this compilation.
- name: Build project
shell: bash
run: ./gradlew build --stacktrace
# Upload build artifacts to the workflow report.
# https://github.com/actions/upload-artifact
- name: Capture build artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ github.event.repository.name }}-artifacts-${{ steps.ref.outputs.branch }}
path: |
**/build/libs/*.jar
!buildSrc/**
!common/**
# Publish artifacts, continuing on error. Incurs reconfiguration overhead.
- name: GitHub
id: github
shell: bash
if: inputs.github && (inputs.fabric || inputs.neoforge)
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FABRIC_TASK: ${{ inputs.fabric && 'fabric:publishGithub' || '' }}
NEOFORGE_TASK: ${{ inputs.neoforge && 'neoforge:publishGithub' || '' }}
run: ./gradlew $FABRIC_TASK $NEOFORGE_TASK --stacktrace
- name: Modrinth
id: modrinth
shell: bash
if: inputs.modrinth && (inputs.fabric || inputs.neoforge)
continue-on-error: true
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
FABRIC_TASK: ${{ inputs.fabric && 'fabric:publishModrinth' || '' }}
NEOFORGE_TASK: ${{ inputs.neoforge && 'neoforge:publishModrinth' || '' }}
SYNC_MODRINTH_DESCRIPTION: ${{ inputs.syncModrinthDescription && 'true' || 'false' }}
run: ./gradlew $FABRIC_TASK $NEOFORGE_TASK --stacktrace
- name: CurseForge
id: curseforge
shell: bash
if: inputs.curseforge && (inputs.fabric || inputs.neoforge)
continue-on-error: true
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
FABRIC_TASK: ${{ inputs.fabric && 'fabric:publishCurseforge' || '' }}
NEOFORGE_TASK: ${{ inputs.neoforge && 'neoforge:publishCurseforge' || '' }}
run: ./gradlew $FABRIC_TASK $NEOFORGE_TASK --stacktrace
# Finally, check for publishing errors and fail the task if one was found.
- name: Check publishing errors
shell: bash
if: |
steps.github.outcome == 'failure'
|| steps.modrinth.outcome == 'failure'
|| steps.curseforge.outcome == 'failure'
run: |
echo "Detected an error in a publish task: check the Summary for details"
exit 1