Merge pull request #66 from NightRainMilkyWay:main #117
This file contains 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: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Create Release | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare Configuration | |
run: | | |
CONFIG_ENV=$(cat config.env | grep -w "CONFIG_ENV" | head -n 1 | cut -d "=" -f 2) | |
echo "MODULE_PACKAGING_PATH=$(cat $CONFIG_ENV | grep -w "MODULE_PACKAGING_PATHE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
echo "ZIP_FILENAME=$(cat $CONFIG_ENV | grep -w "ZIP_FILENAME" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
echo "CONFIG_NAME=$(cat $CONFIG_ENV | grep -w "CONFIG_NAME" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
echo "IS_PRERELEASE=$(cat $CONFIG_ENV | grep -w "IS_PRERELEASE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
echo "VERSION=$(cat $CONFIG_ENV | grep -w "VERSION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
echo "FILE=$(cat $CONFIG_ENV | grep -w "FILE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
echo "VERSIONCODE=$(cat $CONFIG_ENV | grep -w "VERSIONCODE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV | |
- name: Update VERSION | |
run: | | |
VERSIONCODE="${{ env.VERSIONCODE }}" | |
VERSION="${{ env.VERSION }}" | |
# 创建 Tritium.json 文件 | |
echo '{ | |
"versionCode": '"${VERSIONCODE}"', | |
"version": "'"${VERSION}"'", | |
"zipUrl": "https://github.moeyy.xyz/https://github.com/TimeBreeze/Tritium/releases/download/'"${VERSION}"'/Magisk_suni_'"${VERSION}"'.zip", | |
"changelog": "https://github.moeyy.xyz/https://github.com/TimeBreeze/Tritium/blob/main/changelog.md" | |
}' > Tritium_suni.json | |
echo '{ | |
"versionCode": '"${VERSIONCODE}"', | |
"version": "'"${VERSION}"'", | |
"zipUrl": "https://github.moeyy.xyz/https://github.com/TimeBreeze/Tritium/releases/download/'"${VERSION}"'/Magisk_fiage_'"${VERSION}"'.zip", | |
"changelog": "https://github.moeyy.xyz/https://github.com/TimeBreeze/Tritium/blob/main/changelog.md" | |
}' > Tritium_fiage.json | |
# 创建 module.prop 文件 | |
echo 'id=ct_module | |
name=Tritium Suni | |
version='"${VERSION}"' | |
versionCode='"${VERSIONCODE}"' | |
author=Tritium Developers | |
description=Optimize performance ing… | |
updateJson=https://github.moeyy.xyz/https://github.com/TimeBreeze/Tritium/blob/main/Tritium_suni.json | |
' > ./magisk_suni/module.prop | |
echo 'id=ct_module | |
name=Tritium Fiage | |
version='"${VERSION}"' | |
versionCode='"${VERSIONCODE}"' | |
author=Tritium Developers | |
description=Optimize performance ing… | |
updateJson=https://github.moeyy.xyz/https://github.com/TimeBreeze/Tritium/blob/main/Tritium_fiage.json | |
' > ./magisk_fiage/module.prop | |
- name: Zip Module | |
run: | | |
cd $GITHUB_WORKSPACE/magisk_suni | |
zip -r $GITHUB_WORKSPACE/${ZIP_FILENAME}_suni_${VERSION}.zip ./* | |
cd configs | |
zip -r $GITHUB_WORKSPACE/${CONFIG_NAME}_suni_${VERSION}.zip ./* | |
cd ../../. | |
cd $GITHUB_WORKSPACE/magisk_fiage | |
zip -r $GITHUB_WORKSPACE/${ZIP_FILENAME}_fiage_${VERSION}.zip ./* | |
cd configs | |
zip -r $GITHUB_WORKSPACE/${CONFIG_NAME}_fiage_${VERSION}.zip ./* | |
cd ../../. | |
- name: Validate File Hash with Output File | |
run: | | |
sha256sum $GITHUB_WORKSPACE/${ZIP_FILENAME}_suni_${VERSION}.zip > $GITHUB_WORKSPACE/${ZIP_FILENAME}_suni_${VERSION}.hash | |
sha256sum $GITHUB_WORKSPACE/${ZIP_FILENAME}_fiage_${VERSION}.zip > $GITHUB_WORKSPACE/${ZIP_FILENAME}_fiage_${VERSION}.hash | |
cat $GITHUB_WORKSPACE/${ZIP_FILENAME}_suni_${VERSION}.hash | |
cat $GITHUB_WORKSPACE/${ZIP_FILENAME}_fiage_${VERSION}.hash | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub Token 访问权限 | |
with: | |
tag_name: ${{ env.VERSION }} | |
body_path: ${{ github.workspace }}/changelog.md | |
name: Tritium_${{ env.VERSION }} | |
prerelease: ${{ env.IS_PRERELEASE }} | |
body: ${{ env.RELEASE_NOTES }} | |
files: | | |
./*.zip | |
./apk/*.apk | |
./*.hash | |
repository: TimeBreeze/Tritium | |
# note you'll typically need to create a personal access token | |
# with permissions to create releases in the other repo | |
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} | |
- name: 同步 repo | |
run: | | |
rm -rf ./*.zip | |
rm -rf ./*.hash | |
bash -c 'if [ $(git status --porcelain | wc -l) -eq 0 ]; then | |
echo "工作树无变更,跳过提交步骤..." | |
else | |
echo "提交文件中..." | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "chore(generated): GitHub Actions Bot 提交的记录" | |
git log -3 --oneline | |
echo "推送更新中..." | |
git push | |
fi' |