-
Notifications
You must be signed in to change notification settings - Fork 18
71 lines (65 loc) · 2.17 KB
/
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
61
62
63
64
65
66
67
68
69
70
71
name: Release miunlock
on:
push:
paths:
- MiUnlockTool.py
pull_request:
paths:
- MiUnlockTool.py
workflow_dispatch:
jobs:
linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get version
id: get_version
run: |
version=$(grep -oP '(?<=version = ")(.*)(?=")' MiUnlockTool.py)
echo "VERSION=$version" >> $GITHUB_ENV
- name: tag
run: |
if ! git ls-remote --tags origin | grep -q "$VERSION"; then
git tag "$VERSION"
git push origin "$VERSION"
else
echo "Tag $VERSION already exists, skipping tag creation."
fi
- name: release
run: |
if ! gh release view $VERSION; then
gh release create $VERSION --title "Release $VERSION"
else
echo "Release $VERSION already exists, skipping release creation."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ env.VERSION }}
- name: upload
run: |
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
if git diff --name-only HEAD~1 HEAD | grep -q "MiUnlockTool.py"; then
commit_message=$(git log -1 --pretty=format:"%s" -- MiUnlockTool.py)
old_notes=$(gh release view $VERSION --json body -q '.body')
if [ -z "$old_notes" ]; then
notes="$commit_message"
else
if [ "$old_notes" = "$commit_message" ]; then
notes="$commit_message"
else
notes="${old_notes}\n$commit_message"
fi
fi
new_notes=$(echo -e "$notes")
gh release edit $VERSION --notes "$new_notes"
else
echo "MiUnlockTool.py was not modified in the last commit, skipping notes update."
fi
else
echo "No previous commit to compare with."
fi
gh release upload $VERSION ./MiUnlockTool.py --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ env.VERSION }}