feat: update [workflows] release and debug

This commit is contained in:
taamarin
2023-06-11 05:27:32 +07:00
parent 599c3a9af1
commit bbeb8018ae
3 changed files with 97 additions and 11 deletions

View File

@@ -3,6 +3,10 @@ name: debug
on:
workflow_dispatch:
push:
paths-ignore:
- "docs/**"
- "README.md"
- "CHANGELOG.md"
branches:
- master
@@ -16,16 +20,70 @@ jobs:
- name: Get Version
id: get_version
run: |
sed -i "s/v[0-9]\+\.[0-9]\+\.[0-9]\+/&_$(date +%Y%m%d_%H%M)_debug/g" module.prop
echo "version=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT"
echo "date=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Generate Asset
run: |
sudo mkdir -p /box_for_root
sudo cp -r --parents $(find ./ -type f ! -path './.git/*' ! -name 'CHANGELOG.md' ! -name 'update.json' ! -name 'build.sh' ! -path './.github/*' ! -path './docs/*') /box_for_root/
- name: Upload Debug Asset => (box_for_magisk_${{ steps.get_version.outputs.version }}_$(date +%Y%m%d))
- name: Upload Debug Asset => (box_for_magisk_${{ steps.get_version.outputs.version }})
uses: actions/upload-artifact@v3
with:
name: "box_for_magisk_${{ steps.get_version.outputs.version }}_${{ steps.get_version.outputs.date }}"
name: "box_for_magisk_${{ steps.get_version.outputs.version }}"
path: /box_for_root/
upload:
name: Telegram Upload Release
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Get Version and Build
id: get_version
run: |
sed -i "s/v[0-9]\+\.[0-9]\+\.[0-9]\+/&_$(date +%Y%m%d_%H%M)_debug/g" module.prop
sh build.sh
- name: Release
run: |
mkdir bfr
find -name "*.zip" -exec cp {} bfr \;
function upload() {
for file in $@; do
echo ">> Uploading $file"
curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \
-X POST \
-F chat_id="${{ secrets.TELEGRAM_TO }}" \
-F document="@$file" \
--silent --show-error --fail >/dev/null &
done
for job in $(jobs -p); do
wait $job || exit 1
done
}
upload bfr/*
commit:
name: Commit GitHub
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: get commit url
id: commit_url
run: |
echo "::set-output name=commit::$(git log -1 --pretty=format:%s)"
# echo "::set-output name=url::https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
- name: send commit to telegram
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: "${{ steps.commit_url.outputs.commit }}"

View File

@@ -1,24 +1,52 @@
name: release
# description:
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
branch:
description: 'Push Changes'
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Version
id: get_version
run: |
echo "date=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Update update.json and module.prop
run: |
echo '{
"version": "${{ github.event.inputs.tag }}",
"versionCode": "${{ steps.get_version.outputs.date }}",
"zipUrl": "https://github.com/taamarin/box_for_magisk/releases/download/${{ github.event.inputs.tag }}/box_for_root-${{ github.event.inputs.tag }}.zip",
"changelog": "https://github.com/taamarin/box_for_magisk/raw/master/CHANGELOG.md"
}' > update.json
sed -i "s/$(grep -oP 'version=\K[^ ]+' module.prop)/${{ github.event.inputs.tag }}/g" module.prop
sed -i "s/$(grep -oP 'versionCode=\K[^ ]+' module.prop)/$(date +%Y%m%d)/g" module.prop
- name: Commit and push changes
run: |
git config --local user.email "${{ secrets.GH_EMAIL }}"
git config --local user.name "taamarin"
git add update.json module.prop
git commit -m "${{ github.event.inputs.tag }}"
git push -f origin "${{github.event.inputs.branch}}"
- name: run build.sh
run: sh build.sh
run: |
sh build.sh
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
tag_name: ${{ github.event.inputs.tag }}
files: box_for_root-v*.zip
generate_release_notes: true