Skip to content

Commit

Permalink
Workflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
creeper-0910 committed May 6, 2023
1 parent 81f1919 commit c9f2ef7
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
61 changes: 59 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,69 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- uses: robinraju/[email protected]
with:
repository: "iBotPeaches/Apktool"
latest: true
fileName: "*.jar"
- name: sign
run: |
tag_version=`git describe --tags --abbrev=0`
echo "current tag: ${tag_version}"
echo "tag_version=${tag_version}" >> $GITHUB_OUTPUT
sudo apt update
sudo apt -y install apksigner
sudo apt -y install apksigner zipalign jq
updateURL=`curl "${{ secrets.API_URL }}" | jq -r .updateURL`
version=`curl "${{ secrets.API_URL }}" | jq -r .version`
versionTitle=`curl "${{ secrets.API_URL }}" | jq -r .versionTitle`
echo "version=${version}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
echo "tag_version=${tag_version}" >> $GITHUB_OUTPUT
curl -L "$updateURL" -o adguard.apk
echo "${{ secrets.SIGN_KEY }}" | base64 -d > sign.keystore
mv apktool_*.jar apktool.jar
java -jar apktool.jar d adguard.apk --use-aapt2
python main.py "${version}" "${versionTitle}"
curl -L "https://github.com/creeper-0910/adg_translate_ja/raw/main/plurals.xml" -o ./adguard/res/values-ja/plurals.xml
curl -L "https://github.com/creeper-0910/adg_translate_ja/raw/main/strings.xml" -o ./adguard/res/values-ja/strings.xml
java -jar apktool.jar b adguard -o adguard_rebuild.apk --use-aapt2
zipalign -f -v 4 adguard_rebuild.apk adguard_aligned.apk
apksigner sign --ks sign.keystore --ks-pass ${{ secrets.KEY }} -v adguard_aligned.apk
cat src/index.ts
id: version
- uses: rickstaa/action-create-tag@v1
if: steps.version.outputs.tag_version != steps.version.outputs.version
id: tag_create
with:
tag: ${{ steps.version.outputs.version }}
tag_exists_error: false
message: "release ${{ steps.version.outputs.versionTitle }}"
- uses: actions/[email protected]
id: create_release
if: steps.version.outputs.tag_version != steps.version.outputs.version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: Release ${{ steps.version.outputs.versionTitle }}
draft: false
prerelease: false
- uses: actions/upload-release-asset@v1
if: steps.version.outputs.tag_version != steps.version.outputs.version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./adguard_aligned.apk
asset_name: adguard.apk
asset_content_type: application/vnd.android.package-archive
- name: Cleanup
run: |
rm -rf adguard sign.keystore apktool.jar adguard_rebuild.apk adguard_aligned.apk adguard.apk
ls
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
node_modules
node_modules
*.apk
*.keystore
*.jar
adguard
*.xml
19 changes: 19 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
import re
import sys
import glob
args = sys.argv
beforeWord = 'https://mobile-api.adguard.org/api/2.0/checkupdate.html'
afterWord = 'https://upd-adgrd.cf-inagi-saki.workers.dev/'
files = glob.glob("./adguard/**/*.smali", recursive=True)
for file in files :
with open(file, "r") as f :
result = [ row.replace(beforeWord, afterWord) for row in f ]
with open(file, "w") as f :
f.writelines(result)
with open("src/index.ts", 'r') as f:
content = f.read()
result = re.sub(r'const latest_version = "(.*)"', "const latest_version = \""+args[1]+"\"", content)
result = re.sub(r'const latest_display_version = "(.*)"', "const latest_display_version = \""+args[2]+"\"", content)
with open("src/index.ts", 'w') as f:
f.write(result)
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface API {
}

const app = new Hono();
const latest_version = "4.0.826"
const latest_display_version = "4.0 Nightly 99"

// バージョンの表記方法を定義
class Version {
Expand All @@ -45,8 +47,6 @@ class Version {
isOlder(version: Version): boolean {
// バージョン比較関数
// 与えられたバージョより古い場合はtrueを返す
console.log(Number.isInteger(version.patch));
console.log(Number.isInteger(this.patch));
if (this.major !== version.major) {
return true;
} else if (this.minor !== version.minor) {
Expand All @@ -59,25 +59,30 @@ class Version {
}
}


app.get("/", (c) => {
console.log(c.req.query("app_version"))
if (c.req.query("app_version") === undefined) {
return c.text("",400);
}
const version = new Version(String(c.req.query("app_version")));
const latest = new Version("4.0.819");
const latest = new Version(latest_version);
if (version.isOlder(latest)) {
const update_url = new URL(
"https://github.com/creeper-0910/adg_update_srv/releases/download/4.0.819/adguard_4.0.819.apk",
"https://github.com/creeper-0910/adg_update_srv/releases/latest/download/adguard.apk",
);

const content: API = {
version: latest.toString(),
updateURL: update_url.toString(),
updatePageURL: "https://kb.adguard.com/general/adguard-beta-testing-program",
releaseNotes: "これは、AdGuardのNightlyビルドの更新です。このアップデートチャネルは不安定であることをご了承ください。\r\n\r\n## バージョン 4.0 Nightly 97\r\n\r\n* [Fixed] JP Hack!",
releaseNotes: "これは、AdGuardのNightlyビルドの更新です。このアップデートチャネルは不安定であることをご了承ください。\r\n\r\n## バージョン "+latest_display_version.toString()+"\r\n\r\n* [Fixed] JP Hack!",
moreInfoURL: "* [Fixed] JP Hack!",
forced: false,
dotnetVersion: null,
dotnetDownloadLink: null,
dotnetOfficialLink: null,
versionTitle: "4.0 Nightly 99",
versionTitle: latest_display_version.toString(),
major: false,
};

Expand Down

0 comments on commit c9f2ef7

Please sign in to comment.