Skip to content

build & ci: Setup version naming scheme & auto release CI #4

build & ci: Setup version naming scheme & auto release CI

build & ci: Setup version naming scheme & auto release CI #4

Workflow file for this run

name: Build from Pull Request
on: [pull_request]
jobs:
build-pr:
strategy:
matrix:
# Use thses Java versions:
java: [17, 20] # Current Java LTS and current latest Java version
# Use these operating systems:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Show Java version
run: java -version
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Show Gradle version
run: gradle --version
- name: Build with Gradle
run: gradle build --stacktrace
- name: Get Mod Info
id: get_mod_info
uses: christian-draeger/read-properties@1.1.1
with:
path: gradle.properties
properties: 'mod_name mod_version'
- name: Get commit SHA
id: get_commit_sha
run: |
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7)
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
- name: Get commit count
id: get_commit_count
run: |
commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l)
echo "commit_count=$commit_count" >> $GITHUB_OUTPUT
- name: Upload assets to GitHub Action
uses: actions/upload-artifact@v3
with:
name: "[PR-CI#${{ github.run_number }}] ${{ steps.get_mod_info.outputs.mod_name }} ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }} - Java ${{ matrix.java }}"
path: build/libs/*.jar