summaryrefslogtreecommitdiff
path: root/.github/workflows/nightly.yaml
blob: 33de76393d53aace69afa196b13c39ea2aa2e844 (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
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
name: Nightly Release

on:
  push:
    branches:
      - main
    paths-ignore:
      - 'docs/**'
      - '*.md'
      - 'LICENSE'

concurrency:
  group: nightly-release
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-24.04
    outputs:
      version: ${{ steps.version.outputs.version }}
      paper_jar_name: ${{ steps.version.outputs.paper_jar_name }}
      velocity_jar_name: ${{ steps.version.outputs.velocity_jar_name }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Compute nightly version
        id: version
        run: |
          BASE_VERSION=$(grep '?: "' build.gradle.kts | head -1 | sed 's/.*?: "\(.*\)"/\1/')
          if [ -z "$BASE_VERSION" ]; then
            BASE_VERSION="1.0.0"
          fi
          SHORT_HASH=$(git rev-parse --short HEAD)
          NIGHTLY_VERSION="${BASE_VERSION}-nightly.${SHORT_HASH}"
          echo "version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT
          echo "paper_jar_name=LunaticChat-${NIGHTLY_VERSION}.jar" >> $GITHUB_OUTPUT
          echo "velocity_jar_name=LunaticChat-${NIGHTLY_VERSION}-velocity.jar" >> $GITHUB_OUTPUT
          echo "Nightly version: $NIGHTLY_VERSION"

      - name: Setup Development Environment
        uses: jdx/mise-action@v4

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

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew

      - name: Build with shadowJar
        run: |
          ./gradlew :platform-paper:shadowJar :platform-velocity:shadowJar \
            -Pversion="${{ steps.version.outputs.version }}" \
            -PisNightly=true \
            --parallel --no-daemon

      - name: Upload build artifacts
        uses: actions/upload-artifact@v7
        with:
          name: LunaticChat-nightly-${{ steps.version.outputs.version }}
          path: |
            platform-paper/build/libs/${{ steps.version.outputs.paper_jar_name }}
            platform-velocity/build/libs/${{ steps.version.outputs.velocity_jar_name }}
          retention-days: 7

  release:
    runs-on: ubuntu-24.04
    needs: build
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Download build artifact
        uses: actions/download-artifact@v8
        with:
          name: LunaticChat-nightly-${{ needs.build.outputs.version }}

      - name: Delete existing nightly release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          gh release delete nightly --yes --cleanup-tag 2>/dev/null || true

      - name: Create nightly release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          VERSION=${{ needs.build.outputs.version }}
          PAPER_JAR_NAME=${{ needs.build.outputs.paper_jar_name }}
          VELOCITY_JAR_NAME=${{ needs.build.outputs.velocity_jar_name }}

          gh release create nightly \
            "platform-paper/build/libs/$PAPER_JAR_NAME" \
            "platform-velocity/build/libs/$VELOCITY_JAR_NAME" \
            --title "Nightly Build ($VERSION)" \
            --prerelease \
            --notes "$(cat <<'EOF'
          ## ⚠️ Nightly Build

          This is an automatically generated nightly build from the latest `main` branch.

          **Warning:** This build may be unstable or contain bugs. Do not use in production environments.

          - **Version:** `${{ needs.build.outputs.version }}`
          - **Commit:** ${{ github.sha }}

          If you encounter any issues, please report them on [GitHub Issues](https://github.com/m1sk9/LunaticChat/issues).
          EOF
          )"