Skip to content

Download+Release Tasker #200

Download+Release Tasker

Download+Release Tasker #200

name: Download+Release Tasker
# Controls when the workflow will run
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * SUN,WED'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
apk:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'schklom/Tasker-apk'
ref: 'main' # branch
token: ${{ secrets.PAT_GITHUB_ACTION }}
- name: Get apk from Google Drive
run: |
filename="./Tasker.Direct.apk"
echo "filename=${filename}" >> $GITHUB_ENV
fileid=${{ secrets.TASKER_GOOGLE_DRIVE_FILE_ID }}
url="https://drive.usercontent.google.com/download?id=${fileid}&export=download&authuser=0&confirm=t"
curl -L "https://drive.usercontent.google.com/download?id=${fileid}&export=download&authuser=0&confirm=t=${fileid}" -o ${filename}
- name: Store md5 hash of new apk
run: md5sum "${{ env.filename }}" | cut -d " " -f 1 > hash_new_file
- name: Read current and new hash of apk
run: |
echo "current_hash=$(cat hash_current_file)" >> $GITHUB_ENV
echo "new_hash=$(cat hash_new_file)" >> $GITHUB_ENV
- name: Record last update date and update current hash
if: ${{ env.current_hash != env.new_hash }}
run: |
date +%Y-%m-%d_%H-%M > last_update_date
echo "last_update_date_env=$(cat last_update_date)" >> $GITHUB_ENV
mv hash_new_file hash_current_file
# https://code.whatever.social/questions/13469147/get-android-apk-file-versionname-or-versioncode-without-installing-apk
- name: Find version number
if: ${{ env.current_hash != env.new_hash }}
run: |
sudo apt-get install -y aapt
ls -alh
version=`aapt dump badging ${{ env.filename }} | grep -Po "(?<=\sversionName=')([0-9.]+)"`
echo "version=${version}" >> $GITHUB_ENV
# unzip -d apk_files ${{ env.filename }}
# echo "version=$(grep "Version" apk_files/assets/about.html | grep -oP '[0-9\.]+')" >> $GITHUB_ENV
# rm -rf apk_files
- name: Write tag name
if: ${{ env.current_hash != env.new_hash }}
#run: echo "tagname=${{ env.version }}_${{ env.last_update_date_env }}" >> $GITHUB_ENV
run: |
ver="${{ env.version }}"
last_update="${{ env.last_update_date_env }}"
tagname="${ver}_${last_update}"
echo "tagname=${tagname}" >> $GITHUB_ENV
- name: Commit and push the change
if: ${{ env.current_hash != env.new_hash }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update the apk, its hash, and update date
- name: Release apk if hashes are different
if: ${{ env.current_hash != env.new_hash }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.tagname }}
body: "New version of Tasker Direct Purchase"
files: ${{ env.filename }}
repository: "schklom/Tasker-apk"
token: ${{ secrets.PAT_GITHUB_ACTION }}