Skip to content

1.6.6 尝试工作流优化 #59

1.6.6 尝试工作流优化

1.6.6 尝试工作流优化 #59

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Decode and set up Maven settings
run: echo "${{ secrets.MAVEN_SETTINGS_BASE64 }}" | base64 --decode > $HOME/.m2/settings.xml
- name: Build with Maven
run: mvn --batch-mode clean install
- name: Extract Maven version
id: version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Find built JAR
id: find-jar
run: |
JAR_PATH=$(find target -name '*.jar' | grep -v 'original' | head -n 1)
echo "JAR_PATH=$JAR_PATH" >> $GITHUB_ENV
echo "jar_path=$JAR_PATH" >> $GITHUB_OUTPUT
- name: Upload JAR to Artifacts
uses: actions/upload-artifact@v4
with:
name: PlayerMenu-${{ env.VERSION }}.jar
path: ${{ env.JAR_PATH }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: github.event_name == 'push'
with:
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
body: |
Commit: ${{ github.event.head_commit.message }}
files: ${{ env.JAR_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}