Skip to content

Commit 010b293

Browse files
author
pompurin404
committed
custom release
1 parent 093b74c commit 010b293

File tree

4 files changed

+95
-10
lines changed

4 files changed

+95
-10
lines changed

.github/workflows/build.yml

+61-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
push:
44
branches:
55
- master
6+
tags:
7+
- v*
8+
69
permissions: write-all
710

811
jobs:
@@ -33,16 +36,30 @@ jobs:
3336
pnpm install
3437
pnpm prepare --${{ matrix.arch }}
3538
- name: Build
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3839
run: pnpm build:win --${{ matrix.arch }}
39-
4040
- name: Upload Artifacts
4141
uses: actions/upload-artifact@v4
4242
with:
4343
name: Windows ${{ matrix.arch }}
4444
path: dist/*.exe
4545
if-no-files-found: error
46+
- name: Publish Release
47+
if: startsWith(github.ref, 'refs/tags/v')
48+
uses: softprops/action-gh-release@v2
49+
with:
50+
files: |
51+
dist/*.exe
52+
dist/*.blockmap
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
- name: Merge Yaml
55+
if: startsWith(github.ref, 'refs/tags/v')
56+
run: pnpm updater latest.yml
57+
- name: Publish Release
58+
if: startsWith(github.ref, 'refs/tags/v')
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
files: dist/latest.yml
62+
token: ${{ secrets.GITHUB_TOKEN }}
4663

4764
linux:
4865
strategy:
@@ -70,10 +87,7 @@ jobs:
7087
pnpm install
7188
pnpm prepare --${{ matrix.arch }}
7289
- name: Build
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7590
run: pnpm build:linux --${{ matrix.arch }}
76-
7791
- name: Upload Artifacts
7892
uses: actions/upload-artifact@v4
7993
with:
@@ -82,6 +96,29 @@ jobs:
8296
dist/*.deb
8397
dist/*.rpm
8498
if-no-files-found: error
99+
- name: Publish Release
100+
if: startsWith(github.ref, 'refs/tags/v')
101+
uses: softprops/action-gh-release@v2
102+
with:
103+
files: |
104+
dist/*.deb
105+
dist/*.rpm
106+
dist/*.blockmap
107+
token: ${{ secrets.GITHUB_TOKEN }}
108+
- name: Merge Yaml
109+
if: startsWith(github.ref, 'refs/tags/v') && matrix.arch == 'x64'
110+
run: pnpm updater latest-linux.yml
111+
- name: Merge Yaml
112+
if: startsWith(github.ref, 'refs/tags/v') && matrix.arch == 'arm64'
113+
run: pnpm updater latest-linux-arm64.yml
114+
- name: Publish Release
115+
if: startsWith(github.ref, 'refs/tags/v')
116+
uses: softprops/action-gh-release@v2
117+
with:
118+
files: |
119+
dist/latest-linux.yml
120+
dist/latest-linux-arm64.yml
121+
token: ${{ secrets.GITHUB_TOKEN }}
85122

86123
macos:
87124
strategy:
@@ -119,3 +156,21 @@ jobs:
119156
name: MacOS ${{ matrix.arch }}
120157
path: dist/*.dmg
121158
if-no-files-found: error
159+
- name: Publish Release
160+
if: startsWith(github.ref, 'refs/tags/v')
161+
uses: softprops/action-gh-release@v2
162+
with:
163+
files: |
164+
dist/*.dmg
165+
dist/*.zip
166+
dist/*.blockmap
167+
token: ${{ secrets.GITHUB_TOKEN }}
168+
- name: Merge Yaml
169+
if: startsWith(github.ref, 'refs/tags/v')
170+
run: pnpm updater latest-mac.yml
171+
- name: Publish Release
172+
if: startsWith(github.ref, 'refs/tags/v')
173+
uses: softprops/action-gh-release@v2
174+
with:
175+
files: dist/latest-mac.yml
176+
token: ${{ secrets.GITHUB_TOKEN }}

electron-builder.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,4 @@ linux:
5454
category: Utility
5555
artifactName: ${name}-linux-${version}-${arch}.${ext}
5656
npmRebuild: false
57-
publish:
58-
provider: github
59-
owner: pompurin404
60-
repo: mihomo-party
57+
publish: 'never'

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
1313
"typecheck": "npm run typecheck:node && npm run typecheck:web",
1414
"prepare": "node scripts/prepare.mjs",
15+
"updater": "node scripts/updater.mjs",
1516
"dev": "electron-vite dev",
1617
"postinstall": "electron-builder install-app-deps",
1718
"build:win": "electron-vite build && electron-builder --win",

scripts/updater.mjs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2+
import axios from 'axios'
3+
import yaml from 'yaml'
4+
import fs from 'fs'
5+
6+
let file = 'latest.yml'
7+
if (process.argv.slice(2).length !== 0) {
8+
file = process.argv.slice(2)[0]
9+
}
10+
11+
async function check() {
12+
try {
13+
const res = await axios.get(
14+
`https://github.com/pompurin404/mihomo-party/releases/latest/download/${file}`,
15+
{
16+
headers: { 'Content-Type': 'application/octet-stream' }
17+
}
18+
)
19+
const remoteData = yaml.parse(res.data)
20+
const currentData = yaml.parse(fs.readFileSync(`dist/${file}`, 'utf8'))
21+
remoteData.files.push(...currentData.files)
22+
remoteData.releaseDate = `${new Date().toISOString()}`
23+
fs.writeFileSync(`dist/${file}`, yaml.stringify(remoteData))
24+
} catch (error) {
25+
return
26+
}
27+
}
28+
29+
check().catch((error) => {
30+
console.error(error)
31+
process.exit(0)
32+
})

0 commit comments

Comments
 (0)