-
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (72 loc) · 2.61 KB
/
release.yml
File metadata and controls
81 lines (72 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Release PixTab
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # 每天凌晨 0:00 UTC 运行
jobs:
build_and_release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史以进行差异对比
- name: Check for new commits since last version tag
id: check_updates
run: |
VERSION=$(node -e "console.log(require('./manifest.json').version)")
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
COMMITS=$(git rev-list "$TAG..HEAD" --count)
if [ "$COMMITS" -eq 0 ]; then
echo "No new commits since $TAG. Skipping release."
echo "SKIP=true" >> $GITHUB_OUTPUT
else
echo "$COMMITS new commits found since $TAG."
echo "SKIP=false" >> $GITHUB_OUTPUT
fi
else
echo "Tag $TAG does not exist. Proceeding with new release."
echo "SKIP=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.check_updates.outputs.SKIP != 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Make build script executable
if: steps.check_updates.outputs.SKIP != 'true'
run: chmod +x build/build.sh
- name: Build extension
if: steps.check_updates.outputs.SKIP != 'true'
run: ./build/build.sh
- name: Get version from manifest.json
if: steps.check_updates.outputs.SKIP != 'true'
id: get_version
run: |
VERSION=$(node -e "console.log(require('./manifest.json').version)")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Update Git Tag
if: steps.check_updates.outputs.SKIP != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f v${{ steps.get_version.outputs.VERSION }}
git push origin v${{ steps.get_version.outputs.VERSION }} --force
- name: Create or Update GitHub Release
if: steps.check_updates.outputs.SKIP != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
name: PixTab v${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
dist/*.zip
dist/*.xpi