mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 新增 GitHub Actions 工作流文件 auto-tag.yml - 实现基于提交信息的关键字跳过机制 ([skip release] / [no tag]) - 自动解析最新语义化版本号并递增修订号 - 使用 PAT 推送新标签到远程仓库 - 输出版本变更相关信息供后续步骤使用
73 lines
2.2 KiB
YAML
73 lines
2.2 KiB
YAML
name: Create Release (on tag)
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository (at tag)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: true
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: 9.0.x
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --no-restore -c Release
|
|
|
|
- name: Pack
|
|
run: dotnet pack --no-build -c Release -o ./packages
|
|
|
|
- name: Get Version from .nupkg
|
|
id: get_version
|
|
run: |
|
|
set -e
|
|
PACKAGE_FILE=$(find ./packages -name "*.nupkg" | head -n 1)
|
|
if [ -z "$PACKAGE_FILE" ]; then
|
|
echo "No .nupkg file found in ./packages"
|
|
exit 1
|
|
fi
|
|
VERSION=$(unzip -p "$PACKAGE_FILE" *.nuspec 2>/dev/null | sed -n 's:.*<version>\(.*\)</version>.*:\1:p' | head -n1)
|
|
if [ -z "$VERSION" ]; then
|
|
echo "Failed to parse version from $PACKAGE_FILE"
|
|
exit 1
|
|
fi
|
|
echo "package_file=$PACKAGE_FILE" >> $GITHUB_OUTPUT
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create GitHub Release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
release_name: "Release ${{ github.ref_name }}"
|
|
body: "Release created by CI for tag ${{ github.ref_name }} (package version ${{ steps.get_version.outputs.version }})"
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Upload .nupkg to Release
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ${{ steps.get_version.outputs.package_file }}
|
|
asset_name: ${{ steps.get_version.outputs.package_file && (steps.get_version.outputs.package_file | basename) || 'package.nupkg' }}
|
|
asset_content_type: application/octet-stream
|