1+ name : Release
2+
3+ on :
4+ workflow_dispatch :
5+
6+ permissions :
7+ contents : write
8+
9+ jobs :
10+ release :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+ with :
17+ fetch-depth : 0
18+
19+ - name : Compute version info
20+ id : ver
21+ run : |
22+ SHORT=$(git rev-parse --short HEAD)
23+ CODE=$(git rev-list --count HEAD)
24+ MAJOR=$(grep '^version=' module.prop | sed 's/version=\([0-9]*\).*/\1/')
25+ VERSION="${MAJOR}.$(( CODE )) (${CODE}-${SHORT}-release)"
26+ TAG="v${MAJOR}.${CODE}-${SHORT}"
27+ echo "short=$SHORT" >> $GITHUB_OUTPUT
28+ echo "code=$CODE" >> $GITHUB_OUTPUT
29+ echo "version=$VERSION" >> $GITHUB_OUTPUT
30+ echo "tag=$TAG" >> $GITHUB_OUTPUT
31+
32+ - name : Generate sha256 files
33+ run : |
34+ find . \
35+ -not -path './.git/*' \
36+ -not -name '*.sha256' \
37+ -not -name 'update.Json' \
38+ -type f | while read -r f; do
39+ sha256sum "$f" | awk '{print $1}' > "${f}.sha256"
40+ done
41+
42+ - name : Update module.prop
43+ run : |
44+ sed -i "s/^version=.*/version=${{ steps.ver.outputs.version }}/" module.prop
45+ sed -i "s/^versionCode=.*/versionCode=${{ steps.ver.outputs.code }}/" module.prop
46+
47+ - name : Build zip
48+ id : zip
49+ run : |
50+ ZIPNAME="YetAnotherBootloopProtector-${{ steps.ver.outputs.code }}-${{ steps.ver.outputs.tag }}.zip"
51+ # Exclude .git, update.Json (updated separately after release), and README
52+ zip -r "$ZIPNAME" . \
53+ -x '.git/*' \
54+ -x '.github/*' \
55+ -x 'update.Json' \
56+ -x 'README.md' \
57+ -x '*.zip'
58+ echo "zipname=$ZIPNAME" >> $GITHUB_OUTPUT
59+
60+ - name : Create GitHub release
61+ id : release
62+ uses : softprops/action-gh-release@v2
63+ with :
64+ tag_name : ${{ steps.ver.outputs.tag }}
65+ name : ${{ steps.ver.outputs.version }}
66+ body_path : changelog.md
67+ files : ${{ steps.zip.outputs.zipname }}
68+
69+ - name : Update update.Json
70+ run : |
71+ cat > update.Json <<EOF
72+ {
73+ "versionCode": ${{ steps.ver.outputs.code }},
74+ "version": "${{ steps.ver.outputs.version }}",
75+ "zipUrl": "${{ fromJson(steps.release.outputs.assets)[0].browser_download_url }}",
76+ "changelog": "https://raw.githubusercontent.com/${{ github.repository }}/main/changelog.md"
77+ }
78+ EOF
79+
80+ - name : Commit and push updated files
81+ run : |
82+ git config user.name "github-actions[bot]"
83+ git config user.email "github-actions[bot]@users.noreply.github.com"
84+ git add '*.sha256' '*/*.sha256' '*/*/*.sha256' '*/*/*/*.sha256' module.prop update.Json
85+ git commit -m "chore: release ${{ steps.ver.outputs.tag }} [skip ci]"
86+ git push
0 commit comments