Files
Minecraft-place-mod/.github/workflows/release.yml
T
AxTps 3cd76bcbba ci: 新增 GitHub Actions 编译与发布 workflow
build.yml:push/PR 到 main 及手动触发时编译,产物上传 artifact。release.yml:push v* tag 或手动触发时构建并发 GitHub Release,版本号从 tag 推导(v0.1 → 0.1),用 -Pmod_version 覆盖。均用 JDK 25(temurin),直接 ./gradlew,不依赖额外 action。
2026-10-03 15:49:31 +08:00

56 lines
1.3 KiB
YAML
Raw 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@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
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 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