-
Notifications
You must be signed in to change notification settings - Fork 5
91 lines (76 loc) · 3.08 KB
/
Copy pathrelease.yml
File metadata and controls
91 lines (76 loc) · 3.08 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
name: Release build
# Builds every Minecraft version and loader of a release tag and attaches the jars to the GitHub release.
# Settings: .github/release.toml [build]. Helper: .github/scripts/release.py
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Release tag to build and attach jars to
type: string
required: true
task:
description: Gradle task instead of the configured one, e.g. build-1.20.1 to rebuild a single version
type: string
required: false
concurrency:
group: release-${{ github.event.release.tag_name || inputs.tag }}
cancel-in-progress: false
permissions:
contents: write
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
jobs:
build:
name: Build ${{ github.event.release.tag_name || inputs.tag }}
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ env.TAG }}
uses: actions/checkout@v7
with:
ref: ${{ env.TAG }}
- name: Read build settings
id: settings
run: |
set -euo pipefail
echo "java=$(python3 .github/scripts/release.py config build.java)" >> "$GITHUB_OUTPUT"
echo "task=$(python3 .github/scripts/release.py config build.task)" >> "$GITHUB_OUTPUT"
- name: Set up JDK ${{ steps.settings.outputs.java }}
uses: actions/setup-java@v6
with:
java-version: ${{ steps.settings.outputs.java }}
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
# ubuntu-latest has ~14 GB free, a Loom build of several Minecraft versions needs about that much
- name: Free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/.ghcup /opt/hostedtoolcache/CodeQL
# --continue: a failing version does not stop the others, their jars still get attached
- name: Build (${{ inputs.task || steps.settings.outputs.task }})
id: build
continue-on-error: true
run: |
chmod +x ./gradlew
./gradlew ${{ inputs.task || steps.settings.outputs.task }} --continue --stacktrace
- name: Collect release jars
id: collect
run: python3 .github/scripts/release.py collect
- name: Attach jars to the release
if: steps.collect.outputs.found == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "$TAG" build/release-assets/*.jar --repo "${{ github.repository }}" --clobber
- name: Keep jars as workflow artifact
if: steps.collect.outputs.found == 'true'
uses: actions/upload-artifact@v7
with:
name: release-${{ env.TAG }}
path: build/release-assets/*.jar
retention-days: 14
if-no-files-found: error
- name: Fail on build errors
if: steps.build.outcome != 'success'
run: |
echo "::error::The Gradle build failed, see the Build step. Jars of the versions that did build were attached anyway, rerun with a single task (e.g. build-1.20.1) once fixed."
exit 1