aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: dfc10a0bb34b718437c02fd1752d24d078dbb6c1 (plain)
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
name: Run Gradle Build
on:
    - push
    - pull_request

jobs:
    gradle:
        runs-on: ubuntu-latest
        steps:
            -   name: Checkout source
                uses: actions/checkout@v4.1.1

            -   name: Setup Java
                uses: actions/setup-java@v4.0.0
                with:
                    distribution: temurin
                    java-version: 17

            -   name: Setup Gradle
                uses: gradle/actions/setup-gradle@v3

            -   name: Execute Gradle build
                run: ./gradlew build

            -   name: Upload built mod JAR
                uses: actions/upload-artifact@v4.3.0
                with:
                    name: mod-jar
                    path: build/libs/*.jar
    release:
        runs-on: ubuntu-latest
        needs: gradle
        permissions: write-all
        if: ${{ 'push' == github.event_name && 'master' == github.ref_name && '758196864' == github.repository_id }}
        steps:
            -   name: Set repository context
                uses: actions/checkout@v4
            -   name: Download artifact
                uses: actions/download-artifact@v4
                with:
                    name: mod-jar
            -   name: Update release
                run: |
                    echo Generating notes
                    (
                        echo "Automatically generated nightly release. This release is updated on each new commit"
                        echo
                        echo Generated from commit: \`$(git rev-parse HEAD)\`
                    )> release-notes.md
                    cat release-notes.md
                    echo Deleting all existing nightly assets
                    gh release view nightly --json assets \
                    | jq '.assets[]|.name' -r \
                    | while IFS= read -r name;
                    do
                        gh release delete-asset -y -- nightly "$name";
                    done
                    echo Pushing current commit to nightly ref
                    git tag -f nightly
                    git push -f origin nightly
                    echo Upload release
                    gh release upload nightly -- "$(echo *.jar)"
                    gh release edit nightly -F release-notes.md
                env:
                    GH_TOKEN: ${{ github.token }}