Release #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: 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: 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: 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 |