Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
ab0d516d
There was an error fetching the commit references. Please try again later.
Unverified
Commit
ab0d516d
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
chore: updater proxy
parent
b756ae39
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/release.mjs
+35
-2
35 additions, 2 deletions
scripts/release.mjs
src-tauri/tauri.conf.json
+2
-1
2 additions, 1 deletion
src-tauri/tauri.conf.json
with
37 additions
and
3 deletions
scripts/release.mjs
+
35
−
2
View file @
ab0d516d
...
@@ -3,6 +3,7 @@ import { getOctokit, context } from "@actions/github";
...
@@ -3,6 +3,7 @@ import { getOctokit, context } from "@actions/github";
const
UPDATE_TAG_NAME
=
"
updater
"
;
const
UPDATE_TAG_NAME
=
"
updater
"
;
const
UPDATE_JSON_FILE
=
"
update.json
"
;
const
UPDATE_JSON_FILE
=
"
update.json
"
;
const
UPDATE_JSON_PROXY
=
"
update-proxy.json
"
;
/// generate update.json
/// generate update.json
/// upload to update tag's release asset
/// upload to update tag's release asset
...
@@ -83,7 +84,7 @@ async function resolveRelease() {
...
@@ -83,7 +84,7 @@ async function resolveRelease() {
console
.
log
(
updateData
);
console
.
log
(
updateData
);
// maybe should test the signature as well
// maybe should test the signature as well
const
{
darwin
,
win64
}
=
updateData
.
platforms
;
const
{
darwin
,
win64
,
linux
}
=
updateData
.
platforms
;
if
(
!
darwin
.
url
)
{
if
(
!
darwin
.
url
)
{
console
.
log
(
`[Error]: failed to parse release for darwin`
);
console
.
log
(
`[Error]: failed to parse release for darwin`
);
delete
updateData
.
platforms
.
darwin
;
delete
updateData
.
platforms
.
darwin
;
...
@@ -92,6 +93,24 @@ async function resolveRelease() {
...
@@ -92,6 +93,24 @@ async function resolveRelease() {
console
.
log
(
`[Error]: failed to parse release for win64`
);
console
.
log
(
`[Error]: failed to parse release for win64`
);
delete
updateData
.
platforms
.
win64
;
delete
updateData
.
platforms
.
win64
;
}
}
if
(
!
linux
.
url
)
{
console
.
log
(
`[Error]: failed to parse release for linux`
);
delete
updateData
.
platforms
.
linux
;
}
// 生成一个代理github的更新文件
// 使用 https://hub.fastgit.xyz/ 做github资源的加速
const
updateDataNew
=
JSON
.
parse
(
JSON
.
stringify
(
updateData
));
Object
.
keys
(
updateDataNew
.
platforms
).
forEach
((
key
)
=>
{
if
(
updateDataNew
.
platforms
[
key
])
{
updateDataNew
.
platforms
[
key
].
url
=
updateDataNew
.
platforms
[
key
].
url
.
replace
(
"
https://github.com/
"
,
"
https://hub.fastgit.xyz/
"
);
}
else
{
console
.
log
(
`[Error]: updateDataNew.platforms.
${
key
}
is null`
);
}
});
// update the update.json
// update the update.json
const
{
data
:
updateRelease
}
=
await
github
.
rest
.
repos
.
getReleaseByTag
({
const
{
data
:
updateRelease
}
=
await
github
.
rest
.
repos
.
getReleaseByTag
({
...
@@ -99,22 +118,36 @@ async function resolveRelease() {
...
@@ -99,22 +118,36 @@ async function resolveRelease() {
tag
:
UPDATE_TAG_NAME
,
tag
:
UPDATE_TAG_NAME
,
});
});
// delete the old assets
for
(
let
asset
of
updateRelease
.
assets
)
{
for
(
let
asset
of
updateRelease
.
assets
)
{
if
(
asset
.
name
===
UPDATE_JSON_FILE
)
{
if
(
asset
.
name
===
UPDATE_JSON_FILE
)
{
await
github
.
rest
.
repos
.
deleteReleaseAsset
({
await
github
.
rest
.
repos
.
deleteReleaseAsset
({
...
options
,
...
options
,
asset_id
:
asset
.
id
,
asset_id
:
asset
.
id
,
});
});
break
;
}
if
(
asset
.
name
===
UPDATE_JSON_PROXY
)
{
await
github
.
rest
.
repos
.
deleteReleaseAsset
({
...
options
,
asset_id
:
asset
.
id
})
.
catch
(
console
.
error
);
// do not break the pipeline
}
}
}
}
// upload assets
await
github
.
rest
.
repos
.
uploadReleaseAsset
({
await
github
.
rest
.
repos
.
uploadReleaseAsset
({
...
options
,
...
options
,
release_id
:
updateRelease
.
id
,
release_id
:
updateRelease
.
id
,
name
:
UPDATE_JSON_FILE
,
name
:
UPDATE_JSON_FILE
,
data
:
JSON
.
stringify
(
updateData
,
null
,
2
),
data
:
JSON
.
stringify
(
updateData
,
null
,
2
),
});
});
await
github
.
rest
.
repos
.
uploadReleaseAsset
({
...
options
,
release_id
:
updateRelease
.
id
,
name
:
UPDATE_JSON_PROXY
,
data
:
JSON
.
stringify
(
updateDataNew
,
null
,
2
),
});
}
}
// get the signature file content
// get the signature file content
...
...
This diff is collapsed.
Click to expand it.
src-tauri/tauri.conf.json
+
2
−
1
View file @
ab0d516d
...
@@ -52,7 +52,8 @@
...
@@ -52,7 +52,8 @@
"updater"
:
{
"updater"
:
{
"active"
:
true
,
"active"
:
true
,
"endpoints"
:
[
"endpoints"
:
[
"https://github.com/zzzgydi/clash-verge/releases/download/updater/update.json"
"https://github.com/zzzgydi/clash-verge/releases/download/updater/update.json"
,
"https://hub.fastgit.xyz/zzzgydi/clash-verge/releases/download/updater/update-proxy.json"
],
],
"dialog"
:
false
,
"dialog"
:
false
,
"pubkey"
:
"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDExNUFBNTBBN0FDNEFBRTUKUldUbHFzUjZDcVZhRVRJM25NS3NkSFlFVElxUkNZMzZ6bHUwRVJjb2F3alJXVzRaeDdSaTA2YWYK"
"pubkey"
:
"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDExNUFBNTBBN0FDNEFBRTUKUldUbHFzUjZDcVZhRVRJM25NS3NkSFlFVElxUkNZMzZ6bHUwRVJjb2F3alJXVzRaeDdSaTA2YWYK"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment