101 lines
3.9 KiB
YAML
101 lines
3.9 KiB
YAML
name: Release Magisk module NR
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
create-release:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Read module.prop
|
|
id: module_prop
|
|
run: |
|
|
VERSION=$(grep "version=" p9_nr_platform_mod/module.prop | cut -d= -f2)
|
|
VERSIONCODE=$(grep "versionCode=" p9_nr_platform_mod/module.prop | cut -d= -f2)
|
|
echo "MOD_VERSION=$VERSION" >> $GITHUB_ENV
|
|
echo "MOD_VERSIONCODE=$VERSIONCODE" >> $GITHUB_ENV
|
|
echo "RELEASE_TAG=NR-v$VERSIONCODE" >> $GITHUB_ENV
|
|
|
|
- name: Zip folder
|
|
working-directory: ./
|
|
run: |
|
|
cd p9_nr_platform_mod
|
|
zip -r ../p9_nr_platform_mod_v${{ env.MOD_VERSION }}.zip ./*
|
|
cd ..
|
|
|
|
- name: Create Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.REPO_TOKEN }}
|
|
run: |
|
|
# Create the release using Gitea API
|
|
curl -X POST \
|
|
"https://git.hnrk.io/api/v1/repos/henrik/pixel9-EU-combos/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"tag_name": "${{ env.RELEASE_TAG }}",
|
|
"name": "Release ${{ env.RELEASE_TAG }}",
|
|
"body": "NR Module Release ${{ env.MOD_VERSION }}",
|
|
"draft": false,
|
|
"prerelease": false
|
|
}'
|
|
|
|
# Upload the release asset
|
|
RELEASE_ID=$(curl -s \
|
|
"https://git.hnrk.io/api/v1/repos/henrik/pixel9-EU-combos/releases/tags/${{ env.RELEASE_TAG }}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
|
|
curl -X POST \
|
|
"https://git.hnrk.io/api/v1/repos/henrik/pixel9-EU-combos/releases/${RELEASE_ID}/assets?name=p9_nr_platform_mod_v${{ env.MOD_VERSION }}.zip" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/zip" \
|
|
--data-binary @"p9_nr_platform_mod_v${{ env.MOD_VERSION }}.zip"
|
|
|
|
- name: Update updater JSON
|
|
run: |
|
|
cat > updaterNR.json << EOF
|
|
{
|
|
"version": "${{ env.MOD_VERSION }}",
|
|
"versionCode": ${{ env.MOD_VERSIONCODE }},
|
|
"zipUrl": "https://git.hnrk.io/henrik/pixel9-EU-combos/releases/download/${{ env.RELEASE_TAG }}/p9_nr_platform_mod_v${{ env.MOD_VERSION }}.zip",
|
|
"changelog": "https://git.hnrk.io/henrik/pixel9-EU-combos/raw/branch/main/changelog-NR.md"
|
|
}
|
|
EOF
|
|
|
|
- name: Commit and push updater JSON
|
|
run: |
|
|
git config --local user.email "action@gitea.com"
|
|
git config --local user.name "Gitea Action"
|
|
git add updaterNR.json
|
|
git commit -m "Update updaterNR.json for version ${{ env.MOD_VERSION }}"
|
|
git push
|
|
|
|
- name: Send to Telegram
|
|
env:
|
|
BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
|
CHAT_ID_1: ${{ secrets.TELEGRAM_CHAT_ID_1_GROUP }}
|
|
CHAT_ID_2: ${{ secrets.TELEGRAM_CHAT_ID_2 }}
|
|
run: |
|
|
# Send to first chat (with error checking)
|
|
if ! curl -s -f -o /dev/null -F document=@"p9_nr_platform_mod_v${{ env.MOD_VERSION }}.zip" \
|
|
-F caption="New NR Module Release ${{ env.RELEASE_TAG }}" \
|
|
"https://api.telegram.org/bot${BOT_TOKEN}/sendDocument?chat_id=${CHAT_ID_1}"; then
|
|
echo "Failed to send to first chat"
|
|
exit 1
|
|
fi
|
|
|
|
# Send to second chat (with error checking)
|
|
# if ! curl -s -f -o /dev/null -F document=@"p9_nr_platform_mod_v${{ env.MOD_VERSION }}.zip" \
|
|
# -F caption="New NR Module Release ${{ env.RELEASE_TAG }}" \
|
|
# "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument?chat_id=${CHAT_ID_2}"; then
|
|
# echo "Failed to send to second chat"
|
|
# exit 1
|
|
# fi
|