Skip to content

Patch and Release APK #6

Patch and Release APK

Patch and Release APK #6

name: Patch and Release
on:
workflow_dispatch:
inputs:
no-release:
description: "Don't release"
type: boolean
default: false
env:
APK_NAME: patched-snapchat
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Set JAVA_HOME
run: echo "JAVA_HOME=$(echo ${{ steps.setup-java.outputs.java-home }})" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # required for github-action-get-previous-tag
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl
shell: bash
- name: Install unzip
run: sudo apt-get install unzip -y
- name: Install pup
run: |
wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip -O pup.zip
unzip pup.zip
chmod +x pup
sudo mv pup /usr/local/bin/
working-directory: .
- name: Grant execute permissions to script
run: chmod +x script.sh
working-directory: .
- name: Run APK Download Script
run: |
./script.sh
- name: Fetch latest release information
id: fetch-release
run: |
repo_owner="rhunk"
repo_name="SnapEnhance"
api_url="https://api.github.com/repos/${repo_owner}/${repo_name}/releases/latest"
release_info=$(curl -s "$api_url")
release_id=$(echo $release_info | jq -r '.id')
release_tag_name=$(echo $release_info | jq -r '.tag_name')
# Find the asset URL for APK files
asset_url=""
for asset in $(echo $release_info | jq -c '.assets[]'); do
asset_name=$(echo $asset | jq -r '.name')
if [[ $asset_name == *"armv8"* && $asset_name == *".apk" ]]; then
asset_url=$(echo $asset | jq -r '.browser_download_url')
break
fi
done
echo "snapenhance_release_id=$release_id" >> $GITHUB_ENV
echo "snapenhance_release_tag_name=$release_tag_name" >> $GITHUB_ENV
echo "snapenhance_asset_url=$asset_url" >> $GITHUB_ENV
shell: bash
- name: Download the latest APK
run: |
release_id="${{ env.snapenhance_release_id }}"
asset_url="${{ env.snapenhance_asset_url }}"
release_tag_name="${{ env.snapenhance_release_tag_name }}"
wget "$asset_url" -O "$GITHUB_WORKSPACE/snapenhance-${{ env.snapenhance_release_tag_name }}.apk"
shell: bash
- name: Rename Snapchat apk
run: |
mv ./snap.apk ./original-snapchat.apk
- name: Run the command
run: |
java -jar lspatch.jar -m snapenhance-${{ env.snapenhance_release_tag_name }}.apk -f -l 2 -v original-snapchat.apk
- name: Rename patched apk
run: |
mv ./original-snapchat-402-lspatched.apk ./${{ env.APK_NAME }}.apk
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.APK_NAME }}.apk
path: ./${{ env.APK_NAME }}.apk
- name: Get previous tag
id: previoustag
uses: 'WyriHaximus/[email protected]'
with:
fallback: 'v2.0.0'
- name: REGEX last version for 1st-3rd part
id: REGEX_1st-3rd_part
uses: 'frabert/[email protected]'
with:
pattern: 'v(\d+)\.(\d+)\.(\d+)\.(\d+)'
string: ${{ steps.previoustag.outputs.tag }}
replace-with: 'v$1.$2.$3'
- name: REGEX last version for 4th part
id: REGEX_4th_part
uses: 'frabert/[email protected]'
with:
pattern: 'v(\d+)\.(\d+)\.(\d+)\.(\d+)'
string: ${{ steps.previoustag.outputs.tag }}
replace-with: '$4'
- name: Up the version
id: semver
if: ${{ env.snapenhance_release_tag_name == steps.REGEX_1st-3rd_part.outputs.replaced }}
uses: 'WyriHaximus/github-action-next-release-version@v1'
with:
version: ${{ steps.REGEX_4th_part.outputs.replaced }}
- name: Create and Publish Release
id: create-publish-release
if: ${{ inputs.no-release != true }}
uses: softprops/[email protected]
with:
tag_name: ${{ steps.semver.outputs.version }}
name: SnapEnhance Patched APK ${{ env.RELEASE_VERSION }}
files: |
${{ env.APK_NAME }}.apk
snapenhance-${{ env.snapenhance_release_tag_name }}.apk
original-snapchat.apk