mirror of
https://github.com/PaiGramTeam/GetToken.git
synced 2024-11-21 14:38:24 +00:00
auto release
This commit is contained in:
parent
72e3a00d5a
commit
4000b0bfeb
18
.github/postbuild.js
vendored
Normal file
18
.github/postbuild.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
const fs = require("fs")
|
||||
const utils = require("./utils");
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const latestVersionInfo = await utils.getAppVersion()
|
||||
let releaseInfo = await utils.getLatestRelease()
|
||||
if (releaseInfo.name !== latestVersionInfo["package_version"]) {
|
||||
releaseInfo = await utils.createRelease(latestVersionInfo["package_version"], undefined)
|
||||
}
|
||||
for (const path of fs.readdirSync("out")) {
|
||||
console.log(`upload ${path}...`)
|
||||
await utils.uploadReleaseAsset(releaseInfo["upload_url"], path)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})()
|
52
.github/utils.js
vendored
Normal file
52
.github/utils.js
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
const fs = require("fs")
|
||||
const axios = require("axios").create({
|
||||
validateStatus: _ => true
|
||||
})
|
||||
|
||||
const repo = "HolographicHat/GetToken"
|
||||
const token = process.env.GHP_TOKEN
|
||||
|
||||
const getAppVersion = async () => {
|
||||
const latestVersionRsp = await axios.get("https://api-takumi.mihoyo.com/ptolemaios/api/getLatestRelease", {
|
||||
headers: {
|
||||
"x-rpc-client_type": "2",
|
||||
"x-rpc-app_version": "2.37.1",
|
||||
"x-rpc-channel": "miyousheluodi"
|
||||
}
|
||||
})
|
||||
return latestVersionRsp.data.data
|
||||
}
|
||||
|
||||
const getLatestRelease = async () => {
|
||||
const repoLatestVersionRsp = await axios.get(`https://api.github.com/repos/${repo}/releases/latest`)
|
||||
return repoLatestVersionRsp.data.name
|
||||
}
|
||||
|
||||
const createRelease = async (name, desc) => {
|
||||
const result = await axios.post(`https://api.github.com/repos/${repo}/releases`, {
|
||||
tag_name: name,
|
||||
name: name,
|
||||
body: desc,
|
||||
generate_release_notes: true
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
return result.data
|
||||
}
|
||||
|
||||
const uploadReleaseAsset = async (url, path) => {
|
||||
const uri = url.substring(0, url.indexOf("{")) + "?name=" + require("path").basename(path)
|
||||
const size = fs.statSync(path).size
|
||||
const data = fs.readFileSync(path)
|
||||
await axios.post(uri, data, {
|
||||
headers: {
|
||||
"Content-Type": "application/vnd.android.package-archive",
|
||||
"Content-Length": `${size}`,
|
||||
"Authorization": `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { getAppVersion, getLatestRelease, createRelease, uploadReleaseAsset }
|
21
.github/workflows/android.yml
vendored
21
.github/workflows/android.yml
vendored
@ -12,6 +12,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GHP_TOKEN: ${{ secrets.GHP_TOKEN }}
|
||||
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
|
||||
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
|
||||
steps:
|
||||
@ -30,19 +31,19 @@ jobs:
|
||||
- name: Install jq
|
||||
run: sudo apt-get install -y jq
|
||||
- name: Download package
|
||||
run: "curl -H 'x-rpc-client_type: 2' -H 'x-rpc-app_version: 2.37.1' -H 'x-rpc-channel: miyousheluodi' https://api-takumi.mihoyo.com/ptolemaios/api/getLatestRelease | jq --raw-output '.data.package_url' | xargs curl -o origin.apk"
|
||||
run: "curl -H 'x-rpc-client_type: 2' -H 'x-rpc-app_version: 2.37.1' -H 'x-rpc-channel: miyousheluodi' https://api-takumi.mihoyo.com/ptolemaios/api/getLatestRelease | jq --raw-output '.data.package_url' | xargs curl -o miyoushe.apk"
|
||||
- name: Patch package
|
||||
run: "mkdir out && mv app/build/outputs/apk/release/app-release.apk out && java -jar gradle/lspatch/jar-v0.5.1-361-release.jar -f -l 2 -m out/app-release.apk -o out/patched.apk origin.apk"
|
||||
run: "mkdir out && mv app/build/outputs/apk/release/app-release.apk . && java -jar gradle/lspatch/jar-v0.5.1-361-release.jar -f -l 2 -m app-release.apk -o out miyoushe.apk && mv app-release.apk out"
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v3.1.0
|
||||
with:
|
||||
name: Artifacts
|
||||
path: out
|
||||
#- name: Set up Node 16
|
||||
# uses: actions/setup-node@v3
|
||||
# with:
|
||||
# node-version: 16
|
||||
#- name: Install depencies
|
||||
# run: npm install axios@0.27.2
|
||||
#- name: Run post build script
|
||||
# run:
|
||||
- name: Set up Node 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- name: Install dependencies
|
||||
run: npm install axios@0.27.2
|
||||
- name: Run post build script
|
||||
run: node .github/postbuild.js
|
||||
|
Loading…
Reference in New Issue
Block a user