-
Notifications
You must be signed in to change notification settings - Fork 15
60 lines (49 loc) · 1.9 KB
/
create_release.yml
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
name: Check and Create Release
on:
push:
branches:
- main
workflow_dispatch:
jobs:
check-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14' # Use the Node.js version you need
- name: Install dependencies
run: npm install
- name: Get package.json version
id: get_version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Get latest release version
id: get_release
run: |
curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name' > latest_release.txt
- name: Compare versions
id: compare_versions
run: |
if [ "$(cat latest_release.txt)" != "$PACKAGE_VERSION" ]; then
echo "Version mismatch"
echo "create_release=true" >> $GITHUB_ENV
else
echo "Version matches"
echo "create_release=false" >> $GITHUB_ENV
fi
- name: Create new release
if: env.create_release == 'true'
run: |
CURRENT_DATE=$(TZ='Asia/Shanghai' date +'%Y-%m-%d %H:%M')
sed -i "s/\$PACKAGE_VERSION/$PACKAGE_VERSION/g" CHANGELOG.md
sed -i "s/\$CURRENT_DATE/$CURRENT_DATE/g" CHANGELOG.md
gh release create "$PACKAGE_VERSION" linuxdo-scripts.user.js \
-t "$PACKAGE_VERSION" \
-n "New release created with version $PACKAGE_VERSION.
$(cat CHANGELOG.md)
[查看 $PACKAGE_VERSION 更新日志](https://github.com/dlzmoe/linuxdo-scripts/blob/main/version-log.md) [点击前往 greasyfork.org 进行安装](https://greasyfork.org/zh-CN/scripts/501827-linuxdo-%E5%A2%9E%E5%BC%BA%E6%8F%92%E4%BB%B6)
发布于:$CURRENT_DATE"
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}