diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8b1efca --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: Build ChatGames + +on: + push: + branches: + - master + - dev + tags: + - 'v*' + pull_request: + branches: + - master + - dev + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: 'maven' + + - name: Get version and git hash + id: vars + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + SHORT_SHA=$(git rev-parse --short HEAD) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT + + - name: Build with Maven + run: mvn clean package --batch-mode --no-transfer-progress + + - name: Collect and rename JARs + run: | + mkdir -p staging + SHORT_SHA=${{ steps.vars.outputs.short_sha }} + cp spigot/target/ChatGames-Spigot-*.jar staging/ChatGames-Spigot-${{ steps.vars.outputs.version }}-${SHORT_SHA}.jar + cp paper/target/ChatGames-Paper-*.jar staging/ChatGames-Paper-${{ steps.vars.outputs.version }}-${SHORT_SHA}.jar + cp folia/target/ChatGames-Folia-*.jar staging/ChatGames-Folia-${{ steps.vars.outputs.version }}-${SHORT_SHA}.jar + cp sponge/target/ChatGames-Sponge-*.jar staging/ChatGames-Sponge-${{ steps.vars.outputs.version }}-${SHORT_SHA}.jar + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: ChatGames-${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.short_sha }} + path: staging/*.jar + if-no-files-found: error + + - name: Create draft release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + draft: true + files: staging/*.jar + generate_release_notes: true