Skip to content

docs: 更新高级教程并集成 Giscus 评论系统 #2

docs: 更新高级教程并集成 Giscus 评论系统

docs: 更新高级教程并集成 Giscus 评论系统 #2

Workflow file for this run

name: Release to Main
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-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: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Update VERSION file
run: |
echo "${{ steps.get_version.outputs.VERSION }}" > VERSION
- name: Update script version
run: |
sed -i "s/CURRENT_VERSION=\".*\"/CURRENT_VERSION=\"${{ steps.get_version.outputs.VERSION }}\"/" PVE-Tools.sh
- name: Install shc
run: |
sudo add-apt-repository ppa:neurobin/ppa -y
sudo apt-get update
sudo apt-get install shc -y
- name: Compile script to binary
run: |
shc -f PVE-Tools.sh -o pve-tools
chmod +x pve-tools
- name: Commit version changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add VERSION PVE-Tools.sh
git commit -m "chore: update version to ${{ steps.get_version.outputs.VERSION }}" || echo "No changes to commit"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Generate release notes
id: release_notes
run: |
# 生成基于提交历史的发布说明
LATEST_TAG=${{ github.ref_name }}
# 尝试获取前一个 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@v1
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref_name }}
body: |
## 版本 ${{ steps.get_version.outputs.VERSION }}
### 更新日志
${{ steps.release_notes.outputs.CHANGELOG }}
### 使用方法
**方式一:直接运行脚本 (推荐)**
```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Mapleawaa/PVE-Tools-9/main/PVE-Tools.sh)"
```
**方式二:下载二进制文件**
下载下方 Assets 中的 `pve-tools`,赋予执行权限后运行:
```bash
chmod +x pve-tools
./pve-tools
```
files: |
pve-tools
PVE-Tools.sh
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}