Files
PVE-Tools-9/.github/workflows/release.yml
2026-07-08 11:45:32 +08:00

92 lines
2.8 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 to Main
on:
push:
tags:
- 'v*.*.*'
- '*.*.*'
- 'v*.*.*-stable'
- '*.*.*-stable'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取所有历史以生成changelog
- name: Get version from tag
id: get_version
run: |
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG#v}
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build single script from modules
run: bash build.sh
- name: Install shc
run: |
sudo add-apt-repository ppa:neurobin/ppa -y
sudo apt-get update
sudo apt-get install -y shc
- name: Compile script to binary (statically linked)
run: |
CFLAGS="-static" shc -r -f dist/PVE-Tools.sh -o pve-tools
chmod +x pve-tools
- name: Generate release notes
id: release_notes
run: |
# 生成基于提交历史的发布说明
LATEST_TAG=${{ steps.get_version.outputs.TAG }}
# 尝试获取前一个 tag如果没有则为空
PREVIOUS_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%an)" $LATEST_TAG)
else
CHANGELOG=$(git log --pretty=format:"- %s (%an)" $PREVIOUS_TAG..$LATEST_TAG)
fi
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.TAG }}
name: Release ${{ steps.get_version.outputs.TAG }}
body: |
## 版本 ${{ steps.get_version.outputs.VERSION }}
### 更新日志
${{ steps.release_notes.outputs.CHANGELOG }}
### 使用方法
**方式一:直接运行脚本 (推荐)**
```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/PVE-Tools/PVE-Tools-9/main/PVE-Tools.sh)"
```
**方式二:下载二进制文件**
下载下方 Assets 中的 `pve-tools`,赋予执行权限后运行:
```bash
chmod +x pve-tools
./pve-tools
```
files: |
pve-tools
dist/PVE-Tools.sh
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}