Merge pull request #4 from clashperk/next #1
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: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
schedule: | |
- cron: '0 18 1-31 1-12 *' | |
jobs: | |
versioning: | |
name: Versioning | |
runs-on: ubuntu-latest | |
outputs: | |
new_apk_version: ${{ steps.new_apk_version.outputs.version }} | |
old_apk_version: ${{ steps.old_apk_version.outputs.version }} | |
released: ${{ steps.version_check.outputs.released }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Get APK Version | |
id: get_apk_version | |
uses: fjogeleit/http-request-action@master | |
with: | |
method: GET | |
contentType: 'text/plain' | |
url: https://apk-version-api.vercel.app/api?appId=com.supercell.clashofclans | |
- name: New APK Version | |
id: new_apk_version | |
run: echo "::set-output name=version::$(echo ${{ steps.get_apk_version.outputs.response }})" | |
- name: Old APK Version | |
id: old_apk_version | |
run: echo "::set-output name=version::$(jq --raw-output '.version' package.json)" | |
- name: Output | |
run: echo ${{ steps.old_apk_version.outputs.version }} ${{ steps.new_apk_version.outputs.version }} | |
- name: Check Version | |
id: version_check | |
run: echo '::set-output name=released::${{ steps.old_apk_version.outputs.version != steps.new_apk_version.outputs.version }}' | |
build: | |
name: Build | |
if: needs.versioning.outputs.released == 'true' | |
needs: versioning | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Use Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Clone Google Play DL | |
run: git clone https://github.com/csuvajit/gplaydl.git | |
- name: Install Google Play DL | |
run: | | |
cd gplaydl | |
python setup.py install | |
- name: Donwload APK | |
env: | |
GOOGLE_EMAIL: ${{ secrets.GOOGLE_EMAIL }} | |
GOOGLE_PASSWORD: ${{ secrets.GOOGLE_PASSWORD }} | |
run: | | |
gplaydl configure | |
gplaydl download --packageId com.supercell.clashofclans | |
- name: Convert to ZIP | |
run: cp com.supercell.clashofclans.apk com.supercell.clashofclans.zip | |
- name: Unzip APK | |
run: | | |
mkdir apk | |
unzip com.supercell.clashofclans.zip -d apk | |
rm -rf com.supercell.clashofclans* gplaydl | |
- name: Copy Files | |
run: | | |
rm -rf raw/* | |
mv apk/assets/**/buildings.csv raw | |
mv apk/assets/**/characters.csv raw | |
mv apk/assets/**/heroes.csv raw | |
mv apk/assets/**/pets.csv raw | |
mv apk/assets/**/resources.csv raw | |
mv apk/assets/**/spells.csv raw | |
mv apk/assets/**/super_licences.csv raw | |
mv apk/assets/**/texts.csv raw | |
rm -rf apk | |
- name: Use Node.js 14 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14 | |
- name: NPM Install | |
run: npm i | |
- name: Build | |
run: npm start -- --decompress | |
- name: Bump Version | |
run: npm version --git-tag-version=false --allow-same-version ${{ needs.versioning.outputs.new_apk_version }} | |
- name: Configure Git | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Commit | |
run: | | |
git add --all .; | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit, exiting with code 0" | |
exit 0; | |
else | |
git commit -m "chore: deploy new apk version ${{ needs.versioning.outputs.new_apk_version }}"; | |
git push origin main | |
fi | |