forked from nisovin/MagicSpells
-
Notifications
You must be signed in to change notification settings - Fork 71
66 lines (59 loc) · 2.14 KB
/
build.yml
File metadata and controls
66 lines (59 loc) · 2.14 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
name: Build MagicSpells
# On push events to the "main" branch, this action builds the jar and uploads its artifact.
#
# When triggered on a PR, it will only run if the PR was opened, synced, or newly labelled "Build PR Jar".
# If the PR does not have the "Build PR Jar" label, the action will only build the jar; otherwise, it will also
# upload its artifact. Due to security, the "pr_comment" workflow will follow up to link it in the PR.
on:
push:
branches:
- main
paths-ignore:
- factions/**
- memory/**
- shop/**
- teams/**
- towny/**
pull_request:
types:
- labeled
- synchronize
- opened
- reopened
jobs:
build:
name: Build
if: |
github.event_name == 'push' ||
(github.event.action == 'labeled' && github.event.label.name == 'Build PR Jar') ||
github.event.action != 'labeled'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout project sources
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha || github.sha}}
- name: Get commit hash
id: hash
run: echo "sha_short=$(git rev-parse --short ${{github.event.pull_request.head.sha || github.sha}})" >> $GITHUB_OUTPUT
- name: Get version
id: version
run: echo "version=$(grep version gradle.properties | cut -d"=" -f2 | xargs)" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run build with Gradle Wrapper
run: ./gradlew "-Pversion=${{steps.version.outputs.version}}-${{steps.hash.outputs.sha_short}}" core:build
- name: Upload artifact
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'Build PR Jar')
id: artifact
uses: actions/upload-artifact@v4
with:
name: MagicSpells-${{steps.version.outputs.version}}-${{steps.hash.outputs.sha_short}}
if-no-files-found: error
path: core/build/libs/MagicSpells*.jar