BellCommand v1.4.0-beta.1 更新日志 (Changelog) #31
Workflow file for this run
This file contains hidden or 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 package using Maven and then publish it to GitHub and Modrinth when a tag is pushed | |
| # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path | |
| name: Maven Package | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| actions: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get Commit Message | |
| id: commit | |
| run: | | |
| echo 'message<<EOF' >> $GITHUB_OUTPUT | |
| git log -1 --pretty=%B >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| server-id: github | |
| settings-path: ${{ github.workspace }} | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Upload JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: BellCommand | |
| path: target/bellcommand-*.jar | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| body: | | |
| ${{ steps.commit.outputs.message }} | |
| files: target/bellcommand-*.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to Modrinth | |
| env: | |
| MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
| run: | | |
| JAR_PATH=$(ls target/bellcommand-*.jar | head -n 1) | |
| FILENAME=$(basename $JAR_PATH) | |
| VERSION_TYPE="release" | |
| if [[ "${{ github.ref_name }}" == *"beta"* ]]; then | |
| VERSION_TYPE="beta" | |
| elif [[ "${{ github.ref_name }}" == *"alpha"* ]]; then | |
| VERSION_TYPE="alpha" | |
| fi | |
| # 构造 JSON 数据 | |
| # 注意:game_versions 和 loaders 需要是数组格式 | |
| DATA_JSON=$(cat <<EOF | |
| { | |
| "name": "BellCommand ${{ github.ref_name }}", | |
| "version_number": "${{ github.ref_name }}", | |
| "changelog": $(echo "${{ steps.commit.outputs.message }}" | jq -Rsa .), | |
| "game_versions": ["1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"], | |
| "version_type": "$VERSION_TYPE", | |
| "loaders": ["spigot", "paper", "purpur"], | |
| "project_id": "n18snJd9", | |
| "file_parts": ["file_0"] | |
| } | |
| EOF | |
| ) | |
| # 使用 curl 调用官方 API | |
| curl -X POST \ | |
| -H "Authorization: $MODRINTH_TOKEN" \ | |
| -F "data=$DATA_JSON" \ | |
| -F "file_0=@$JAR_PATH" \ | |
| https://api.modrinth.com/v2/version |