-
Notifications
You must be signed in to change notification settings - Fork 9
84 lines (73 loc) · 2.88 KB
/
r.yml
File metadata and controls
84 lines (73 loc) · 2.88 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
82
83
84
name: Release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute version info
id: ver
run: |
SHORT=$(git rev-parse --short HEAD)
CODE=$(git rev-list --count HEAD)
MAJOR=$(grep '^version=' module.prop | sed 's/version=\([0-9]*\).*/\1/')
echo "short=$SHORT" >> $GITHUB_OUTPUT
echo "code=$CODE" >> $GITHUB_OUTPUT
echo "version=${MAJOR}.${CODE} (${CODE}-${SHORT}-release)" >> $GITHUB_OUTPUT
echo "tag=v${MAJOR}.${CODE}-${SHORT}" >> $GITHUB_OUTPUT
- name: Generate sha256 files
run: |
find . \
-not -path './.git/*' \
-not -path './.github/*' \
-not -name '*.sha256' \
-not -name 'update.Json' \
-type f | while read -r f; do
sha256sum "$f" | awk '{print $1}' > "${f}.sha256"
done
- name: Update module.prop
run: |
sed -i "s/^version=.*/version=${{ steps.ver.outputs.version }}/" module.prop
sed -i "s/^versionCode=.*/versionCode=${{ steps.ver.outputs.code }}/" module.prop
- name: Build zip
id: zip
run: |
ZIPNAME="YetAnotherBootloopProtector-${{ steps.ver.outputs.code }}-${{ steps.ver.outputs.tag }}.zip"
zip -r "$ZIPNAME" . \
-x '.git/*' \
-x '.github/*' \
-x '.github/**/*' \
-x 'update.Json' \
-x 'README.md' \
-x '*.zip'
echo "zipname=$ZIPNAME" >> $GITHUB_OUTPUT
- name: Create GitHub release
id: release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: ${{ steps.ver.outputs.version }}
body_path: changelog.md
files: ${{ steps.zip.outputs.zipname }}
- name: Update update.Json
run: |
jq -n \
--argjson code ${{ steps.ver.outputs.code }} \
--arg version "${{ steps.ver.outputs.version }}" \
--arg zipUrl "${{ fromJson(steps.release.outputs.assets)[0].browser_download_url }}" \
--arg changelog "https://raw.githubusercontent.com/${{ github.repository }}/main/changelog.md" \
'{versionCode: $code, version: $version, zipUrl: $zipUrl, changelog: $changelog}' \
> update.Json
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add module.prop update.Json
git commit -m "chore: release ${{ steps.ver.outputs.tag }} [skip ci]"
git push