changlog #14
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 | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@main | |
- name: 1. 准备文件 | |
run: | | |
echo "version=$(jq -r .version $GITHUB_WORKSPACE/module.json)" >> $GITHUB_ENV | |
echo "versionCode=$(jq -r .versionCode $GITHUB_WORKSPACE/module.json)" >> $GITHUB_ENV | |
echo "ModuleFolderName=module_files" >> $GITHUB_ENV | |
- name: 2. 制作模块 | |
run: | | |
mkdir -p "$GITHUB_WORKSPACE"/GithubRelease | |
echo "version=${{ env.version }}" >>$GITHUB_WORKSPACE/${{ env.ModuleFolderName }}/module.prop | |
echo "versionCode=${{ env.versionCode }}" >>$GITHUB_WORKSPACE/${{ env.ModuleFolderName }}/module.prop | |
cd $GITHUB_WORKSPACE/${{ env.ModuleFolderName }} | |
zip -q -r ${{ env.ModuleFolderName }}.zip * | |
mv $GITHUB_WORKSPACE/${{ env.ModuleFolderName }}/${{ env.ModuleFolderName }}.zip "$GITHUB_WORKSPACE"/GithubRelease | |
- name: 3.上传到Github Release | |
uses: ncipollo/release-action@main | |
with: | |
artifacts: ${{ github.workspace }}/GithubRelease/* | |
name: "OneUI_CSC_Features ${{ env.version }}" | |
tag: "${{ env.version }}" | |
bodyFile: ${{ github.workspace }}/changelog.md # 使用 changelog.md 作为版本描述 | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
makeLatest: true | |
- name: 4. 更新下载链接 | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Mzdyl" | |
sed -i '4d' $GITHUB_WORKSPACE/module.json | |
browser_download_url=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/OWNER/REPO/releases/tags/${{ env.version }} | jq -r .assets[].browser_download_url | cut -d'"' -f2) | |
sed -i '3a "zipUrl": "'"$browser_download_url"'",' $GITHUB_WORKSPACE/module.json | |
jq . $GITHUB_WORKSPACE/module.json > $GITHUB_WORKSPACE/new.json | |
rm -rf $GITHUB_WORKSPACE/module.json && mv $GITHUB_WORKSPACE/new.json $GITHUB_WORKSPACE/module.json | |
git add ./module.json | |
if git commit -m "v${{ env.version }}"; then | |
echo "push=true" >> $GITHUB_ENV | |
else | |
echo "push=false" >> $GITHUB_ENV | |
fi | |
# - name: 5. 更新 .gitattributes | |
# run: | | |
# # 请在引号内自行更新您的Github账号信息 | |
# git config --global user.email "[email protected]" | |
# # 请在引号内自行更新您的Github账号信息 | |
# git config --global user.name "Mzdyl" | |
# sed -i 's/module_files/${{ env.ModuleFolderName }}/g' $GITHUB_WORKSPACE/.gitattributes | |
# git add ./.gitattributes | |
# if git commit -m "更新 .gitattributes"; then | |
# echo "更新 .gitattributes: Success!" | |
# fi | |
- if: ${{ env.push == 'true' }} | |
name: 6. 推送到Magisk Module仓库 | |
uses: ad-m/github-push-action@master | |
with: | |
branch: ${{ github.ref }} |