Skip to content

Commit

Permalink
Initial commit for Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 22, 2024
1 parent a1fd118 commit bd54293
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 3 deletions.
37 changes: 37 additions & 0 deletions .github/bumpVersion.sh
Original file line number Diff line number Diff line change
@@ -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<<EOF' >> $GITHUB_ENV
cat telegram.msg >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
1 change: 1 addition & 0 deletions .github/edit2MakeNewBeta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Editing this file will trigger the build script for a new beta release
23 changes: 23 additions & 0 deletions .github/extractChanges.sh
Original file line number Diff line number Diff line change
@@ -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
80 changes: 80 additions & 0 deletions .github/workflows/makeBetaRelease.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
name: OxygenCustomizer.apk
path: output

- name: Oxygen Customizer Binary Release
uses: ncipollo/[email protected]
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/[email protected]
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: [email protected]
1 change: 1 addition & 0 deletions .github/workflowsFiles/FutureChanageLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-
3 changes: 0 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<!-- Auth For Advanced Power Menu -->
<uses-permission android:name="android.permission.USE_BIOMETRIC" />

<!-- Updater -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
6 changes: 6 additions & 0 deletions latestBeta.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit bd54293

Please sign in to comment.