Workflow file for this run
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: Update Magisk Channel Data | |
on: | |
release: | |
types: | |
- 'published' | |
env: | |
GITHUB_USER: "${{secrets.USERNAME}}" | |
GITHUB_EMAIL: "${{secrets.EMAIL}}" | |
GITHUB_TOKEN: "${{secrets.API_TOKEN_GITHUB}}" | |
GIT_CLONE: "${{ github.workspace }}/git_clone" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Install tools | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y wget jq dos2unix | |
- name: Wget zip file | |
run: | | |
tag=$(echo ${{ github.ref }} | sed "s|refs/tags/||g") | |
wget -P ${{ github.workspace }} https://github.com/chase535/accurate_battery/releases/download/${tag}/accurate_battery.zip | |
- name: Wget and parse releases json | |
run: | | |
tag=$(echo ${{ github.ref }} | sed "s|refs/tags/||g") | |
versioncode=$(echo ${tag} | sed "s|v||g") | |
wget -P ${{ github.workspace }} https://api.github.com/repos/chase535/accurate_battery/releases/tags/${tag} -O releases.json | |
jq -rM '.body' ${{ github.workspace }}/releases.json > ${{ github.workspace }}/changelog.md | |
sed -i "1i # ${tag}" ${{ github.workspace }}/changelog.md | |
sed -i G ${{ github.workspace }}/changelog.md | |
echo "{\"version\": \"${tag}\",\"versionCode\": \"${versioncode}\"}" > ${{ github.workspace }}/version.json | |
- name: Push zip file and modified files | |
run: | | |
tag=$(echo ${{ github.ref }} | sed "s|refs/tags/||g") | |
git config --global user.name "${GITHUB_USER}" | |
git config --global user.email "${GITHUB_EMAIL}" | |
mkdir -vp ${GIT_CLONE} | |
git clone https://"${GITHUB_USER}":"${GITHUB_TOKEN}"@github.com/chase535/accurate_battery.git ${GIT_CLONE} -b main --depth=1 | |
cd ${GIT_CLONE} | |
cp -avf ${{ github.workspace }}/accurate_battery.zip ./update_channel | |
cat ./update_channel/changelog.md >> ${{ github.workspace }}/changelog.md | |
dos2unix ${{ github.workspace }}/changelog.md | |
cp -avf ${{ github.workspace }}/changelog.md ./update_channel | |
jq -sM add ./update_channel/accurate_battery.json ${{ github.workspace }}/version.json > ${{ github.workspace }}/accurate_battery.json | |
dos2unix ${{ github.workspace }}/accurate_battery.json | |
cp -avf ${{ github.workspace }}/accurate_battery.json ./update_channel | |
git add . -f | |
git commit -a -m "更新${tag}版本" | |
git push origin main -f |