From bd54293c29e661662af92134a3af92b77686c064 Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Tue, 23 Apr 2024 00:05:42 +0200 Subject: [PATCH] Initial commit for Updater --- .github/bumpVersion.sh | 37 ++++++++++ .github/edit2MakeNewBeta | 1 + .github/extractChanges.sh | 23 +++++++ .github/workflows/makeBetaRelease.yml | 80 ++++++++++++++++++++++ .github/workflowsFiles/FutureChanageLog.md | 1 + app/build.gradle.kts | 3 - app/src/main/AndroidManifest.xml | 3 + latestBeta.json | 6 ++ 8 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 .github/bumpVersion.sh create mode 100644 .github/edit2MakeNewBeta create mode 100644 .github/extractChanges.sh create mode 100644 .github/workflows/makeBetaRelease.yml create mode 100644 .github/workflowsFiles/FutureChanageLog.md create mode 100644 latestBeta.json diff --git a/.github/bumpVersion.sh b/.github/bumpVersion.sh new file mode 100644 index 000000000..53f6d328a --- /dev/null +++ b/.github/bumpVersion.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +NEWVERCODE=$(($(cat app/build.gradle | grep versionCode | tr -s ' ' | cut -d " " -f 2 | tr -d '\r')+1)) +NEWVERNAME="canary-$NEWVERCODE" + +sed -i 's/versionCode.*/versionCode '$NEWVERCODE'/' app/build.gradle +sed -i 's/versionName.*/versionName "'$NEWVERNAME'"/' app/build.gradle + +sed -i 's/version=.*/version='$NEWVERNAME'/' MagiskModBase/module.prop +sed -i 's/versionCode=.*/versionCode='$NEWVERCODE'/' MagiskModBase/module.prop + +sed -i 's/"version":.*/"version": "'$NEWVERNAME'",/' latestCanary.json +sed -i 's/"versionCode":.*/"versionCode": '$NEWVERCODE',/' latestCanary.json + +sed -i 's/"version":.*/"version": "'$NEWVERNAME'",/' MagiskModuleUpdate_Xposed.json +sed -i 's/"versionCode":.*/"versionCode": '$NEWVERCODE',/' MagiskModuleUpdate_Xposed.json + +sed -i 's/"version":.*/"version": "'$NEWVERNAME'",/' MagiskModuleUpdate_Full.json +sed -i 's/"versionCode":.*/"versionCode": '$NEWVERCODE',/' MagiskModuleUpdate_Full.json + +#sed -i 's/"zipUrl_Xposed":.*/"zipUrl_Xposed": "https:\/\/nightly.link\/siavash79\/AOSPMods\/actions\/runs\/'$1'\/AOSPMods_Xposed.zip",/' latestCanary.json +#sed -i 's/"zipUrl_Full":.*/"zipUrl_Full": "https:\/\/nightly.link\/siavash79\/AOSPMods\/actions\/runs\/'$1'\/AOSPMods_Full.zip",/' latestCanary.json + +# module changelog +echo "**$NEWVERNAME** " > newChangeLog.md +cat changeLog.md >> newChangeLog.md +echo " " >> newChangeLog.md +cat BetaChangelog.md >> newChangeLog.md +mv newChangeLog.md BetaChangelog.md + +echo "*$NEWVERNAME* released in beta channel " > telegram.msg +echo " " >> telegram.msg +echo "*Changelog:* " >> telegram.msg +cat changeLog.md >> telegram.msg +echo 'TMessage<> $GITHUB_ENV +cat telegram.msg >> $GITHUB_ENV +echo 'EOF' >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/edit2MakeNewBeta b/.github/edit2MakeNewBeta new file mode 100644 index 000000000..ab6c8d942 --- /dev/null +++ b/.github/edit2MakeNewBeta @@ -0,0 +1 @@ +Editing this file will trigger the build script for a new beta release \ No newline at end of file diff --git a/.github/extractChanges.sh b/.github/extractChanges.sh new file mode 100644 index 000000000..c21f0047f --- /dev/null +++ b/.github/extractChanges.sh @@ -0,0 +1,23 @@ +#!/bin/bash + + # reset the file - most likely not needd + rm -f changeLog.md + rm -f Tchangelog.htm + touch changeLog.md + touch Tchangelog.htm + + #find the last time we made a changelog + LASTUPDATE=$(git log -100 | grep -B 4 "Version update: Release" | grep "commit" -m 1 | cut -d " " -f 2) + #find commits since - starting with the magic phrase + COMMITS=$(git rev-list $LASTUPDATE..HEAD --grep "^CHANGELOG: ") + #separator is newline + IFS=$'\n' + for COMMIT in $COMMITS + do + COMMITMSGS=$(git show $COMMIT --pretty=format:"%s" | grep "^CHANGELOG: " | tr -d '\0') + for LINE in $COMMITMSGS + do + #save in the temp file to be used by next script + echo "- "${LINE##*CHANGELOG: }" " >> changeLog.md + done + done \ No newline at end of file diff --git a/.github/workflows/makeBetaRelease.yml b/.github/workflows/makeBetaRelease.yml new file mode 100644 index 000000000..bd82e6761 --- /dev/null +++ b/.github/workflows/makeBetaRelease.yml @@ -0,0 +1,80 @@ +name: Make Canary Release + +on: + push: + branches: + - 'beta' + paths: + - '.github/edit2MakeNewBeta' + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Source Code Download + run: git clone --branch canary --single-branch --recurse-submodules https://github.com/DHD2280/Oxygen-Customizer.git . + + - name: JDK 17 Setup + uses: actions/setup-java@v4.1.0 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Shell Scripts Permissions + run: chmod +x .github/*.sh + + - name: Changelog Generation + run: .github/extractChanges.sh + + - name: Version Bump + run: .github/bumpVersion.sh ${{ github.run_id }} + + - name: Gradlew Permissions + run: chmod +x gradlew + + - name: Signature files preparation + run: | + if [ ! -z "${{ secrets.KEYSTORE }}" ]; then + echo storePassword='${{ secrets.KEYSTORE_PASSWORD }}' >> keystore.properties + echo keyAlias='${{ secrets.KEY_ALIAS }}' >> keystore.properties + echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> keystore.properties + echo storeFile='${{ github.workspace }}/key.jks' >> keystore.properties + echo ${{ secrets.KEYSTORE }} | base64 --decode > ${{ github.workspace }}/key.jks + fi + + - name: Gradle Build + run: ./gradlew assembleRelease + + - name: Upload Xposed Artifact to Actions + uses: actions/upload-artifact@v4.3.1 + with: + name: OxygenCustomizer.apk + path: output + + - name: Oxygen Customizer Binary Release + uses: ncipollo/release-action@v1.14.0 + with: + tag: 'beta_builds' + name: 'Latest Beta' + omitBodyDuringUpdate: true + prerelease: true + allowUpdates: true + replacesArtifacts: true + draft: false + artifacts: 'output/*.*' + + - name: Version Bump Commit + uses: github-actions-x/commit@v2.9 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + push-branch: 'beta' + commit-message: 'Version update: Release' + force-add: 'true' + files: app/build.gradle latestVersion.json BetaChangelog.md latestBeta.json + name: GitHub + email: OxygenCustomizer@dhd.it diff --git a/.github/workflowsFiles/FutureChanageLog.md b/.github/workflowsFiles/FutureChanageLog.md new file mode 100644 index 000000000..3cf20d57b --- /dev/null +++ b/.github/workflowsFiles/FutureChanageLog.md @@ -0,0 +1 @@ +- \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b7b981fa7..f1e3fc317 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -98,9 +98,6 @@ dependencies { // Recycler View implementation("androidx.recyclerview:recyclerview:1.3.2") - implementation("androidx.constraintlayout:constraintlayout-core:1.0.4") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - // Work implementation("androidx.work:work-runtime:2.9.0") implementation("androidx.concurrent:concurrent-futures:1.1.0") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 93e52e859..45909356b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,6 +16,9 @@ + + + diff --git a/latestBeta.json b/latestBeta.json new file mode 100644 index 000000000..7e6d58b89 --- /dev/null +++ b/latestBeta.json @@ -0,0 +1,6 @@ +{ + "version": "beta-3", + "versionCode": 3, + "apkUrl": "https://github.com/DHD2280/Oxygen-Customizer/releases/download/beta_builds/OxygenCustomizer.apk", + "changelog": "https://raw.githubusercontent.com/DHD2280/Oxygen-Customizer/beta/BetaChangelog.md" +} \ No newline at end of file