mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: enable scheduled builds and improve asset deletion logic in autobuild workflow
This commit is contained in:
151
.github/workflows/autobuild.yml
vendored
151
.github/workflows/autobuild.yml
vendored
@@ -2,15 +2,15 @@ name: Auto Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
# schedule:
|
schedule:
|
||||||
# UTC+8 0,6,12,18
|
# UTC+8 0,6,12,18
|
||||||
# - cron: "0 16,22,4,10 * * *"
|
- cron: "0 16,22,4,10 * * *"
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
env:
|
env:
|
||||||
|
TAG_NAME: autobuild
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
RUST_BACKTRACE: short
|
RUST_BACKTRACE: short
|
||||||
concurrency:
|
concurrency:
|
||||||
# only allow per workflow per commit (and not pr) to run at a time
|
|
||||||
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
|
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
|
||||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||||
|
|
||||||
@@ -29,32 +29,26 @@ jobs:
|
|||||||
- name: Check if version changed or src changed
|
- name: Check if version changed or src changed
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
# For manual workflow_dispatch, always run
|
|
||||||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Store current version from package.json
|
|
||||||
CURRENT_VERSION=$(cat package.json | jq -r '.version')
|
CURRENT_VERSION=$(cat package.json | jq -r '.version')
|
||||||
echo "Current version: $CURRENT_VERSION"
|
echo "Current version: $CURRENT_VERSION"
|
||||||
|
|
||||||
# Get the previous commit's package.json version
|
|
||||||
git checkout HEAD~1 package.json
|
git checkout HEAD~1 package.json
|
||||||
PREVIOUS_VERSION=$(cat package.json | jq -r '.version')
|
PREVIOUS_VERSION=$(cat package.json | jq -r '.version')
|
||||||
echo "Previous version: $PREVIOUS_VERSION"
|
echo "Previous version: $PREVIOUS_VERSION"
|
||||||
|
|
||||||
# Reset back to current commit
|
|
||||||
git checkout HEAD package.json
|
git checkout HEAD package.json
|
||||||
|
|
||||||
# Check if version changed
|
|
||||||
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
|
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
|
||||||
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
|
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if src or src-tauri directories changed
|
|
||||||
CURRENT_SRC_HASH=$(git rev-parse HEAD:src)
|
CURRENT_SRC_HASH=$(git rev-parse HEAD:src)
|
||||||
PREVIOUS_SRC_HASH=$(git rev-parse HEAD~1:src 2>/dev/null || echo "")
|
PREVIOUS_SRC_HASH=$(git rev-parse HEAD~1:src 2>/dev/null || echo "")
|
||||||
CURRENT_TAURI_HASH=$(git rev-parse HEAD:src-tauri 2>/dev/null || echo "")
|
CURRENT_TAURI_HASH=$(git rev-parse HEAD:src-tauri 2>/dev/null || echo "")
|
||||||
@@ -73,79 +67,74 @@ jobs:
|
|||||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# delete_old_assets:
|
delete_old_assets:
|
||||||
# needs: check_commit
|
name: Delete Old Autobuild Release Assets
|
||||||
# if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
needs: check_commit
|
||||||
# runs-on: ubuntu-latest
|
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
||||||
# steps:
|
runs-on: ubuntu-latest
|
||||||
# - name: Delete Old Alpha Release Assets
|
steps:
|
||||||
# uses: actions/github-script@v7
|
- name: Delete Old Autobuild Release Assets
|
||||||
# with:
|
uses: actions/github-script@v7
|
||||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
with:
|
||||||
# script: |
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# const releaseTag = 'alpha';
|
script: |
|
||||||
|
const releaseTag = '${{ env.TAG_NAME }}';
|
||||||
|
|
||||||
# try {
|
try {
|
||||||
# // Get the release by tag name
|
const { data: release } = await github.rest.repos.getReleaseByTag({
|
||||||
# const { data: release } = await github.rest.repos.getReleaseByTag({
|
owner: context.repo.owner,
|
||||||
# owner: context.repo.owner,
|
repo: context.repo.repo,
|
||||||
# repo: context.repo.repo,
|
tag: releaseTag
|
||||||
# tag: releaseTag
|
});
|
||||||
# });
|
|
||||||
|
|
||||||
# console.log(`Found release with ID: ${release.id}`);
|
console.log(`Found release with ID: ${release.id}`);
|
||||||
|
|
||||||
# // Delete each asset
|
if (release.assets && release.assets.length > 0) {
|
||||||
# if (release.assets && release.assets.length > 0) {
|
console.log(`Deleting ${release.assets.length} assets`);
|
||||||
# console.log(`Deleting ${release.assets.length} assets`);
|
|
||||||
|
|
||||||
# for (const asset of release.assets) {
|
for (const asset of release.assets) {
|
||||||
# console.log(`Deleting asset: ${asset.name} (${asset.id})`);
|
console.log(`Deleting asset: ${asset.name} (${asset.id})`);
|
||||||
# await github.rest.repos.deleteReleaseAsset({
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
# owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
# repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
# asset_id: asset.id
|
asset_id: asset.id
|
||||||
# });
|
});
|
||||||
# }
|
}
|
||||||
|
|
||||||
# console.log('All assets deleted successfully');
|
console.log('All assets deleted successfully');
|
||||||
# } else {
|
} else {
|
||||||
# console.log('No assets found to delete');
|
console.log('No assets found to delete');
|
||||||
# }
|
}
|
||||||
# } catch (error) {
|
} catch (error) {
|
||||||
# if (error.status === 404) {
|
if (error.status === 404) {
|
||||||
# console.log('Release not found, nothing to delete');
|
console.log('Release not found, nothing to delete');
|
||||||
# } else {
|
} else {
|
||||||
# console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
# throw error;
|
throw error;
|
||||||
# }
|
}
|
||||||
# }
|
}
|
||||||
|
|
||||||
update_tag:
|
update_tag:
|
||||||
name: Update tag
|
name: Update tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: check_commit
|
needs: [check_commit, delete_old_assets]
|
||||||
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
if: ${{ needs.check_commit.outputs.should_run == 'true' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Fetch Alpha update logs
|
- name: Fetch UPDATE logs
|
||||||
id: fetch_alpha_logs
|
id: fetch_update_logs
|
||||||
run: |
|
run: |
|
||||||
# Check if UPDATELOG.md exists
|
|
||||||
if [ -f "UPDATELOG.md" ]; then
|
if [ -f "UPDATELOG.md" ]; then
|
||||||
# Extract the section starting with ## and containing -alpha until the next ## or end of file
|
UPDATE_LOGS=$(awk '/^## v/{if(flag) exit; flag=1} flag' UPDATELOG.md)
|
||||||
# ALPHA_LOGS=$(awk '/^## .*-alpha/{flag=1; print; next} /^## /{flag=0} flag' UPDATELOG.md)
|
if [ -n "$UPDATE_LOGS" ]; then
|
||||||
ALPHA_LOGS=$(awk '/^## v/{if(flag) exit; flag=1} flag' UPDATELOG.md)
|
echo "Found update logs"
|
||||||
|
echo "UPDATE_LOGS<<EOF" >> $GITHUB_ENV
|
||||||
if [ -n "$ALPHA_LOGS" ]; then
|
echo "$UPDATE_LOGS" >> $GITHUB_ENV
|
||||||
echo "Found alpha update logs"
|
|
||||||
echo "ALPHA_LOGS<<EOF" >> $GITHUB_ENV
|
|
||||||
echo "$ALPHA_LOGS" >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "No alpha sections found in UPDATELOG.md"
|
echo "No update sections found in UPDATELOG.md"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "UPDATELOG.md file not found"
|
echo "UPDATELOG.md file not found"
|
||||||
@@ -158,17 +147,15 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
# 检查 ALPHA_LOGS 是否存在,如果不存在则使用默认消息
|
if [ -z "$UPDATE_LOGS" ]; then
|
||||||
if [ -z "$ALPHA_LOGS" ]; then
|
echo "No update logs found, using default message"
|
||||||
echo "No alpha logs found, using default message"
|
UPDATE_LOGS="More new features are now supported. Check for detailed changelog soon."
|
||||||
ALPHA_LOGS="More new features are now supported. Check for detailed changelog soon."
|
|
||||||
else
|
else
|
||||||
echo "Using found alpha logs"
|
echo "Using found update logs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 生成 release.txt 文件
|
|
||||||
cat > release.txt << EOF
|
cat > release.txt << EOF
|
||||||
$ALPHA_LOGS
|
$UPDATE_LOGS
|
||||||
|
|
||||||
## 我应该下载哪个版本?
|
## 我应该下载哪个版本?
|
||||||
|
|
||||||
@@ -191,7 +178,6 @@ jobs:
|
|||||||
- arm64架构: arm64_fixed_webview2-setup.exe
|
- arm64架构: arm64_fixed_webview2-setup.exe
|
||||||
|
|
||||||
### FAQ
|
### FAQ
|
||||||
|
|
||||||
- [常见问题](https://clash-verge-rev.github.io/faq/windows.html)
|
- [常见问题](https://clash-verge-rev.github.io/faq/windows.html)
|
||||||
|
|
||||||
### 稳定机场VPN推荐
|
### 稳定机场VPN推荐
|
||||||
@@ -203,7 +189,7 @@ jobs:
|
|||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: autobuild
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
name: "Clash Verge Rev AutoBuild"
|
name: "Clash Verge Rev AutoBuild"
|
||||||
body_path: release.txt
|
body_path: release.txt
|
||||||
prerelease: true
|
prerelease: true
|
||||||
@@ -227,7 +213,6 @@ jobs:
|
|||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
- os: ubuntu-22.04
|
- os: ubuntu-22.04
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
@@ -284,8 +269,8 @@ jobs:
|
|||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||||
with:
|
with:
|
||||||
tagName: alpha
|
tagName: ${{ env.TAG_NAME }}
|
||||||
releaseName: "Clash Verge Rev Alpha"
|
releaseName: "Clash Verge Rev AutoBuild"
|
||||||
releaseBody: "More new features are now supported."
|
releaseBody: "More new features are now supported."
|
||||||
releaseDraft: false
|
releaseDraft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
@@ -340,8 +325,8 @@ jobs:
|
|||||||
- name: Release Autobuild Version
|
- name: Release Autobuild Version
|
||||||
run: pnpm release-version autobuild
|
run: pnpm release-version autobuild
|
||||||
|
|
||||||
- name: "Setup for linux"
|
- name: Setup for linux
|
||||||
run: |-
|
run: |
|
||||||
sudo ls -lR /etc/apt/
|
sudo ls -lR /etc/apt/
|
||||||
|
|
||||||
cat > /tmp/sources.list << EOF
|
cat > /tmp/sources.list << EOF
|
||||||
@@ -375,14 +360,14 @@ jobs:
|
|||||||
patchelf:${{ matrix.arch }} \
|
patchelf:${{ matrix.arch }} \
|
||||||
librsvg2-dev:${{ matrix.arch }}
|
librsvg2-dev:${{ matrix.arch }}
|
||||||
|
|
||||||
- name: "Install aarch64 tools"
|
- name: Install aarch64 tools
|
||||||
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y \
|
sudo apt install -y \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
g++-aarch64-linux-gnu
|
g++-aarch64-linux-gnu
|
||||||
|
|
||||||
- name: "Install armv7 tools"
|
- name: Install armv7 tools
|
||||||
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
|
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y \
|
sudo apt install -y \
|
||||||
@@ -415,7 +400,7 @@ jobs:
|
|||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: autobuild
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
name: "Clash Verge Rev AutoBuild"
|
name: "Clash Verge Rev AutoBuild"
|
||||||
prerelease: true
|
prerelease: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -511,7 +496,7 @@ jobs:
|
|||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: autobuild
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
name: "Clash Verge Rev AutoBuild"
|
name: "Clash Verge Rev AutoBuild"
|
||||||
prerelease: true
|
prerelease: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
Reference in New Issue
Block a user