-
Notifications
You must be signed in to change notification settings - Fork 1.5k
74 lines (74 loc) · 2.51 KB
/
release_new_version.yaml
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
name: Release New Version
on:
workflow_dispatch:
inputs:
release_version:
description: 'new version of ShellClash, such as 1.7.0f'
required: true
type: string
release_type:
required: true
type: choice
options:
- '内测版'
- '公测版'
- '正式版'
env:
new_version: ${{ github.event.inputs.release_version }}
new_type: ${{ github.event.inputs.release_type }}
jobs:
Update:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@main
- name: Update Version Number
if: ${{ github.event.inputs.release_type != '内测版' }}
run: |
if [[ "${new_type}" == "正式版" ]]; then
sed -i "1i ${new_version}" ./bin/release_version
elif [[ "${new_type}" == "公测版" ]]; then
sed -i "s/versionsh=.*/versionsh=${new_version}/" ./bin/version
sed -i "s/version=.*/version=${new_version}/" ./scripts/init.sh
fi
- name: Package
if: ${{ github.event.inputs.release_type != '正式版' }}
run: |
cd ./bin
# 打包 clashfm.tar.gz
rm ./clashfm.tar.gz
mkdir clashfm && pushd clashfm
cp ../../scripts/* ./
chmod +x *
tar zcvf ../clashfm.tar.gz *
popd && rm -fr clashfm
# 打包 ShellClash.tar.gz
rm ./ShellClash.tar.gz
mkdir ShellClash && pushd ShellClash
cp ../../scripts/* ./
chmod +x *
cp ../Country.mmdb ./
tar zcvf ../ShellClash.tar.gz *
popd && rm -fr ./ShellClash
- name: Commit and push
if: ${{ github.event.inputs.release_type != '内测版' }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]"
git add . && git commit -m "${new_type} ${new_version} 打包" || exit 0
git push
if [[ "${new_type}" == "正式版" ]]; then
git tag ${new_version}
git push origin ${new_version}
fi
- name: Package Artifact
id: package_artifact
run: |
mkdir artifacts
cp ./bin/clashfm.tar.gz ./artifacts/
cp ./bin/ShellClash.tar.gz ./artifacts/
echo "artifact_name=${new_type}_${new_version}_$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
- name: Upload Test Artifact
uses: actions/upload-artifact@main
with:
name: ${{ steps.package_artifact.outputs.artifact_name }}
path: ./artifacts/*