Skip to content
Merged
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
47 changes: 40 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: build
on: [pull_request, push]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: validate gradle wrapper
uses: gradle/actions/wrapper-validation@v4

- name: setup jdk
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'microsoft'

- name: make gradle wrapper executable
run: chmod +x ./gradlew

- name: build
run: ./gradlew build

- name: capture build artifacts
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
path: build/libs/*.jar

- name: read gradle.properties release flags
id: release_props
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
SHOULD_RELEASE=$(grep -Po '^shouldRelease=.*' gradle.properties | cut -d= -f2 | xargs)

if [ "$SHOULD_RELEASE" != "true" ]; then
echo "shouldRelease is false — skipping release"
exit 0
fi

MOD_VERSION=$(grep -Po '^modVersion=.*' gradle.properties | cut -d= -f2 | xargs)

echo "SHOULD_RELEASE=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
echo "MOD_VERSION=$MOD_VERSION" >> $GITHUB_OUTPUT

- name: create GitHub release
if: steps.release_props.outputs.SHOULD_RELEASE == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.release_props.outputs.MOD_VERSION }}
name: Cobalt ${{ steps.release_props.outputs.MOD_VERSION }}
files: build/libs/*.jar
body: ${{ github.event.head_commit.message }}
env:
GITHUB_TOKEN: ${{ github.token }}
Loading