-
Notifications
You must be signed in to change notification settings - Fork 31
79 lines (69 loc) · 2.53 KB
/
build.yaml
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
name: Build
on:
push:
pull_request:
# Only allow running one build job at a time to optimise cache hits
concurrency:
group: builds
jobs:
build:
runs-on: ubuntu-latest
# Avoid duplicate runs when both `push` and `pull_request` are triggered:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Calculate metadata
id: data
run: |
# Calculate data
full="${{ github.sha }}"
short="${full:0:6}"
date="$(date --utc +'%Y-%m-%d_%H-%M-%S')"
forge="$(grep --max-count=1 --only-matching --word-regexp '\(neo\)\?forge' gradle.properties)"
minecraft="$(sed -ne 's/^\s*minecraft_version\s*=\s*\(.*\)$/\1/p' gradle.properties)"
# Print to output
echo "full_sha=$full" >> $GITHUB_OUTPUT
echo "short_sha=$short" >> $GITHUB_OUTPUT
echo "date=$date" >> $GITHUB_OUTPUT
echo "forge_name=$forge" >> $GITHUB_OUTPUT
echo "minecraft=$minecraft" >> $GITHUB_OUTPUT
echo "name_suffix=${date}-${short}-mc${minecraft}" >> $GITHUB_OUTPUT
# Print to stdout too
echo Metadata:
cat $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: microsoft
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
run: ./gradlew build
# Upload separately, or they'll be zipped together
- name: Upload all builds
uses: actions/upload-artifact@v4
with:
name: all-builds-${{ steps.data.outputs.name_suffix }}.zip
path: build/libs
retention-days: 30
if-no-files-found: error
- name: Upload Fabric build
uses: actions/upload-artifact@v4
with:
name: freecam-fabric-${{ steps.data.outputs.name_suffix }}.jar
path: |
build/libs/*-fabric-*.jar
!**-modrinth-*.jar
retention-days: 90
if-no-files-found: error
- name: Upload Forge build
uses: actions/upload-artifact@v4
with:
name: freecam-${{ steps.data.outputs.forge_name }}-${{ steps.data.outputs.name_suffix }}.jar
path: |
build/libs/*-${{ steps.data.outputs.forge_name }}-*.jar
!**-modrinth-*.jar
retention-days: 90
if-no-files-found: error