通用数据 #159
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Pull Request Checker | |
on: | |
pull_request: | |
paths: | |
- '.github/workflows/**' | |
- 'src/**' | |
- 'pom.xml' | |
permissions: | |
contents: read | |
packages: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
short-commit-hash: ${{ steps.env-setup.outputs.SHORT_COMMIT_HASH }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: ${{ vars.JAVA_CI_VERSION }} | |
java-package: jdk | |
architecture: x64 | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Codestyle Check | |
run: mvn -s .mvn/settings.xml -B spotless:check compile --errors | |
- name: Build with Maven | |
run: mvn -s .mvn/settings.xml package --errors | |
# Setup for the preview build | |
- name: Environment Setup | |
id: env-setup | |
run: | | |
SHORT_COMMIT_HASH=$(git rev-parse --short=8 ${{ github.sha }}) | |
JAR_VERSION="Preview Build #${{ github.event.number }}-$SHORT_COMMIT_HASH" | |
echo "SHORT_COMMIT_HASH=$SHORT_COMMIT_HASH" >> "$GITHUB_ENV" | |
echo "SHORT_COMMIT_HASH=$SHORT_COMMIT_HASH" >> "$GITHUB_OUTPUT" | |
echo "JAR_VERSION=$JAR_VERSION" >> "$GITHUB_ENV" | |
sed -i "s/<version>5.0-SNAPSHOT<\/version>/<version>$JAR_VERSION<\/version>/g" pom.xml | |
- name: Upload the artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: slimefun-${{ github.event.number }}-${{ env.SHORT_COMMIT_HASH }} | |
path: 'target/Slimefun-${{ env.JAR_VERSION }}.jar' | |
call-workflows: | |
needs: [ build ] | |
uses: ./.github/workflows/e2e-testing.yml | |
with: | |
artifact-name: slimefun-${{ github.event.number }}-${{ needs.build.outputs.short-commit-hash }} |