Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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