Skip to content

Workflow file for this run

name: Build and Release
on:
push:
tags:
- "v*" # 当推送以 v 开头的 tag 时触发(例如 v1.2)
workflow_dispatch: # 允许手动触发
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Build with Maven
run: mvn clean package # 执行 Maven 构建
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: LongTimeNoSee.jar
path: target/LongTimeNoSee-*.jar # 匹配构建生成的 JAR 文件
- name: Create Release
if: success() # 仅在构建成功时执行
uses: softprops/action-gh-release@v1
with:
files: |
target/LongTimeNoSee-*.jar
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-failure:
if: failure() # 仅在构建失败时执行
runs-on: ubuntu-latest
needs: build-and-release # 依赖构建任务
steps:
- name: Send Slack Notification
uses: slackapi/[email protected]
with:
payload: |
{
"text": "❌ 构建失败!仓库: ${{ github.repository }}, 提交: ${{ github.sha }}",
"channel": "#build-notifications"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # 需在仓库设置中配置