Files
AxTps 956295eeda ci: 升级 actions 到 v5(消除弃用警告)
setup-java 升 v4→v5(官方警告点名);checkout、upload-artifact 一并升 v5(已核实 tag 存在)。消除 Node.js 20 弃用与 setup-java v4 弃用警告。
2026-10-03 17:25:04 +08:00

80 lines
2.5 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: '要发布的 tag 名(如 v0.1)'
required: true
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Resolve version from tag
id: ver
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
VERSION="${TAG#v}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build with Gradle
run: ./gradlew build -Pmod_version=${{ steps.ver.outputs.version }} --stacktrace
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: ${{ steps.ver.outputs.tag }}
generate_release_notes: true
files: build/libs/*.jar
draft: false
prerelease: false
- name: Read Modrinth metadata
id: meta
run: |
echo "project_id=$(jq -r .project_id modrinth.json)" >> "$GITHUB_OUTPUT"
echo "loaders=$(jq -r '.loaders | join(\",\")' modrinth.json)" >> "$GITHUB_OUTPUT"
echo "game_versions=$(jq -r '.game_versions | join(\",\")' modrinth.json)" >> "$GITHUB_OUTPUT"
echo "version_type=$(jq -r .version_type modrinth.json)" >> "$GITHUB_OUTPUT"
- name: Publish to Modrinth
# 仅在正式 tag 时发布(跳过含 test 的 tag)
if: ${{ !contains(steps.ver.outputs.tag, 'test') }}
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ steps.meta.outputs.project_id }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files: build/libs/minecraft-place-mod-${{ steps.ver.outputs.version }}.jar
name: ${{ steps.ver.outputs.tag }}
version: ${{ steps.ver.outputs.version }}
version-type: ${{ steps.meta.outputs.version_type }}
loaders: ${{ steps.meta.outputs.loaders }}
game-versions: ${{ steps.meta.outputs.game_versions }}
changelog: 详见 GitHub Release。
modrinth-featured: false