diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml new file mode 100644 index 0000000..c50b19e --- /dev/null +++ b/.github/workflows/beta-release.yml @@ -0,0 +1,61 @@ +name: Release to Beta +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+-beta*' + - 'v[0-9]+.[0-9]+.[0-9]+-alpha*' + +jobs: + beta-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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: 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 beta 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: beta + + - name: Create GitHub Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Beta Release ${{ github.ref }} + body: | + ## Beta 版本 ${{ steps.get_version.outputs.VERSION }} + + ⚠️ 这是测试版本,可能存在不稳定因素,请勿在生产环境使用 + + ## 安装方式 + + ```bash + bash <(curl -sSL https://github.com/Mapleawaa/PVE-Tools-9/blob/beta/PVE-Tools.sh) + ``` + draft: false + prerelease: true \ No newline at end of file diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 0000000..44adcab --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -0,0 +1,41 @@ +name: PR Validation +on: + pull_request: + branches: [ main, beta ] + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Shellcheck + run: | + shellcheck -f gcc PVE-Tools.sh > shellcheck_results.txt || true + cat shellcheck_results.txt || true + if grep -q "error\|warning" shellcheck_results.txt; then + echo "Shellcheck found issues. Please fix them before merging." + exit 1 + fi + + - name: Shell syntax check + run: | + bash -n PVE-Tools.sh + + - name: Version consistency check + run: | + SCRIPT_VERSION=$(grep "CURRENT_VERSION=" PVE-Tools.sh | cut -d'"' -f2) + VERSION_FILE_VERSION=$(cat VERSION 2>/dev/null) + if [ "$SCRIPT_VERSION" != "$VERSION_FILE_VERSION" ]; then + echo "Version inconsistency: script($SCRIPT_VERSION) != version file($VERSION_FILE_VERSION)" + exit 1 + fi + + - name: Security scan + run: | + # 检查是否有潜在的安全问题 + if grep -q "eval\|source" PVE-Tools.sh; then + echo "Potential security issues found: eval or source commands detected" + else + echo "No security issues detected" + fi \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2dc5230 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Release to Main +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-stable' + +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: 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=$(git describe --tags --abbrev=0) + PREVIOUS_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1)) + CHANGELOG=$(git log --pretty=format:"%h - %s (%an)" $PREVIOUS_TAG..$LATEST_TAG) + echo "CHANGELOG<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + ## 版本 ${{ steps.get_version.outputs.VERSION }} + + 自动发布 + + ${{ steps.release_notes.outputs.CHANGELOG }} + + ## 安装方式 + + ```bash + bash <(curl -sSL https://github.com/Mapleawaa/PVE-Tools-9/blob/main/PVE-Tools.sh) + ``` + draft: false + prerelease: false \ No newline at end of file