BlockAds #15
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: BlockAds | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 8 1,15 * *" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create Temp Folder | |
run: mkdir downloads | |
- name: Start Building | |
run: | | |
cd downloads | |
# Get latest version of BlockAds | |
fileVersion=$(curl -s "https://api.github.com/repos/pantsufan/BlockAds/tags" | jq -r '.[0].name') | |
echo $fileVersion | |
fileName="BlockAds-$fileVersion.zip" | |
echo $fileName | |
fileURL="https://github.com/pantsufan/BlockAds/releases/download/$fileVersion/$fileName" | |
wget -q $fileURL | |
unzip -d ZIP $fileName | |
wget -q https://raw.githubusercontent.com/pantsufan/BlockAds/master/hosts | |
cp -u hosts ZIP/system/etc/ | |
rm hosts | |
rm $fileName | |
cd ZIP | |
# Change version number | |
currentVersion=$fileVersion | |
# Extract the major and minor version components | |
major=$(echo "$currentVersion" | awk -F'.' '{print substr($1,2)}') | |
minor=$(echo "$currentVersion" | awk -F'.' '{print $2}') | |
# Increment the minor version, and reset to 0 if it reaches 99 | |
minor=$((minor + 1)) | |
if [ "$minor" -eq 100 ]; then | |
minor=0 | |
major=$((major + 1)) | |
fi | |
# Format the new version | |
newVersion="v${major}.${minor}" | |
echo "id=SH_Blocker | |
name=BlockADs | |
version=$newVersion | |
versionCode=7 | |
author=Kninja | |
description=🔥️ Say Goodbye To Ads Forever" > module.prop | |
zip -r BlockAds-$newVersion.zip * | |
mkdir temp | |
mv BlockAds-$newVersion.zip temp | |
cd .. | |
echo "Build Done" | |
echo newVersion=${newVersion} >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.newVersion }} | |
release_name: BlockAds Module | |
body: | | |
# Changelog | |
- Updated Hosts File | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./downloads/ZIP/temp/BlockAds-${{ env.newVersion }}.zip | |
asset_name: BlockAds-${{ env.newVersion }}.zip | |
asset_content_type: application/zip |