Skip to content

Commit b4e69ea

Browse files
committed
📦 Chore(custom): update publish workflow
1 parent 529ae22 commit b4e69ea

File tree

10 files changed

+308
-251
lines changed

10 files changed

+308
-251
lines changed

.github/workflows/buid_arch.yml

Lines changed: 106 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Build with architecture
33
on:
44
workflow_dispatch:
55
inputs:
6+
tag_name:
7+
description: 'Tag name to build'
8+
required: false
9+
default: 'preview'
10+
type: string
611
publish_enabled:
712
description: 'Publish artifacts after build?'
813
required: true
@@ -34,7 +39,7 @@ on:
3439
- ubuntu-24.04-arm-arm64-rpm
3540
- All
3641
permissions:
37-
contents: read
42+
contents: write
3843

3944
env:
4045
ELECTRON_OUTPUT_PATH: ./dist_electron
@@ -154,10 +159,7 @@ jobs:
154159
yarn global add xvfb-maybe
155160
if [[ "${{ matrix.format }}" == "zip" || "${{ matrix.format }}" == "7z" ]]; then
156161
echo "Target format is ${{ matrix.format }}, downloading all resources..."
157-
yarn run prepare
158-
else
159-
echo "Target format is other, downloading themes only..."
160-
yarn run prepare:themes
162+
yarn run prepare:7za
161163
fi
162164
echo "Checking resources directory:"
163165
ls -alh ./resources/theme || echo "Theme directory not found"
@@ -168,22 +170,6 @@ jobs:
168170
echo "❌ 7za.exe does not exist"
169171
fi
170172
171-
- name: Generate release notes
172-
if: github.event.inputs.build_os == matrix.filter || github.event.inputs.build_os == 'All'
173-
shell: bash
174-
run: |
175-
chmod +x ./scripts/generate-release-notes.sh
176-
./scripts/generate-release-notes.sh
177-
178-
- name: Configure electron-builder.json
179-
if: github.event.inputs.build_os == matrix.filter || github.event.inputs.build_os == 'All'
180-
shell: bash
181-
run: |
182-
# Remove publish config if not publishing
183-
if [ "${{ github.event.inputs.publish_enabled }}" == "false" ]; then
184-
jq 'del(.publish)' electron-builder.json > tmp.json && mv tmp.json electron-builder.json
185-
fi
186-
187173
- name: Build & release app
188174
if: github.event.inputs.build_os == matrix.filter || github.event.inputs.build_os == 'All'
189175
shell: bash
@@ -192,29 +178,19 @@ jobs:
192178
export CSC_IDENTITY_AUTO_DISCOVERY=false
193179
unset CSC_LINK WIN_CSC_LINK CSC_KEY_PASSWORD
194180
fi
195-
PUBLISH_ARG="never"
196-
if [ "${{ github.event.inputs.publish_enabled }}" == "true" ]; then
197-
PUBLISH_ARG="always"
198-
fi
199-
echo "Publishing argument: $PUBLISH_ARG"
200181
if [[ "${{ matrix.os }}" == windows* ]]; then
201-
yarn run build:win ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
182+
yarn run build:win ${{ matrix.format}} --${{ matrix.arch }} --publish never
202183
elif [[ "${{ matrix.os }}" == macos* ]]; then
203-
yarn run build:mac ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
184+
yarn run build:mac ${{ matrix.format}} --${{ matrix.arch }} --publish never
204185
elif [[ "${{ matrix.os }}" == ubuntu* ]]; then
205-
yarn run build:linux ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
186+
yarn run build:linux ${{ matrix.format}} --${{ matrix.arch }} --publish never
206187
else
207188
echo "Unsupported OS: ${{ matrix.os }}"
208189
exit 1
209190
fi
210191
env:
211192
USE_SYSTEM_FPM: ${{ matrix.os == 'ubuntu-24.04-arm' && 'true' || 'false' }}
212193
GH_TOKEN: ${{ secrets.GH_TOKEN }}
213-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
214-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
215-
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
216-
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
217-
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
218194
ELECTRON_SKIP_NOTARIZATION: ${{ secrets.ELECTRON_SKIP_NOTARIZATION }}
219195
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
220196
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
@@ -250,3 +226,99 @@ jobs:
250226
path: dist_electron/**/*.yml
251227
retention-days: 30
252228
if-no-files-found: 'ignore'
229+
230+
combine-and-upload:
231+
name: Combine and Upload Release
232+
needs: build
233+
runs-on: ubuntu-latest
234+
235+
steps:
236+
- name: Check out git repository
237+
uses: actions/checkout@v6
238+
239+
- name: Install Node.js
240+
uses: actions/setup-node@v6
241+
with:
242+
node-version: "22.x"
243+
244+
- name: Install dependencies
245+
shell: bash
246+
run: |
247+
yarn config set ignore-engines true
248+
rm -rf node_modules && yarn install
249+
250+
- name: Generate Release Notes
251+
run: |
252+
chmod +x ./scripts/generate-release-notes.sh
253+
./scripts/generate-release-notes.sh
254+
255+
- name: Download All Artifacts
256+
uses: actions/download-artifact@v4
257+
with:
258+
pattern: '*-artifacts'
259+
path: ./artifacts
260+
261+
- name: Download YML Artifacts
262+
uses: actions/download-artifact@v4
263+
with:
264+
pattern: '*-yml'
265+
path: ./yml-artifacts
266+
merge-multiple: false
267+
268+
- name: List downloaded artifacts
269+
run: |
270+
echo "Downloaded artifacts structure:"
271+
find ./yml-artifacts -type f -name "*.yml"
272+
tree ./yml-artifacts
273+
tree ./artifacts
274+
275+
- name: Combine and deduplicate yml files
276+
run: |
277+
node scripts/combine-yml.cjs ./yml-artifacts ./dist_electron/combined
278+
echo "Combined YML files:"
279+
ls -la ./dist_electron/combined/
280+
echo "Latest combined YML content:"
281+
cat ./dist_electron/combined/latest.yml
282+
echo "Latest macOS combined YML content:"
283+
cat ./dist_electron/combined/latest-mac.yml
284+
echo "Latest linux combined YML content:"
285+
cat ./dist_electron/combined/latest-linux.yml
286+
echo "Latest linux ARM64 combined YML content:"
287+
cat ./dist_electron/combined/latest-linux-arm64.yml
288+
289+
- name: Publish GitHub Dev Release
290+
uses: softprops/action-gh-release@v2
291+
continue-on-error: true
292+
with:
293+
token: ${{ secrets.GH_TOKEN }}
294+
tag_name: ${{ github.event.inputs.tag_name }}
295+
draft: true
296+
prerelease: ${{ github.event.inputs.publish_enabled == 'false' || github.event.inputs.tag_name == 'preview' }}
297+
body_path: ./release-notes.md
298+
name: ${{ github.event.inputs.tag_name }}
299+
files: |
300+
!artifacts/**/*-unpacked/**
301+
artifacts/**/*.exe
302+
artifacts/**/*.dmg
303+
artifacts/**/*.zip
304+
artifacts/**/*.7z
305+
artifacts/**/*.AppImage
306+
artifacts/**/*.deb
307+
artifacts/**/*.snap
308+
artifacts/**/*.rpm
309+
./dist_electron/combined/*.yml
310+
artifacts/**/*.tar.gz
311+
312+
- name: Upload to S3
313+
run: |
314+
if [ "${{ github.event.inputs.publish_enabled }}" == "false" ]; then
315+
echo "Publishing is disabled. Skipping upload to S3."
316+
node scripts/upload-to-s3.js ./artifacts ./dist_electron/combined
317+
exit 0
318+
fi
319+
node scripts/upload-to-s3.js ./artifacts ./dist_electron/combined false
320+
env:
321+
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
322+
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
323+
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
324+

electron-builder.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@
1414
"resources/**"
1515
],
1616
"files": ["out/**/*", "resources/**", "package.json", "!**/node_modules/typescript{,/**}"],
17-
"publish": [
18-
{
19-
"provider": "s3",
20-
"bucket": "piclist-dl",
21-
"region": "auto",
22-
"acl": "private",
23-
"endpoint": "https://7ab4ed5cb1f4052a13d3b573876ecf33.r2.cloudflarestorage.com",
24-
"path": "/latest"
25-
},
26-
{
27-
"provider": "github",
28-
"owner": "Kuingsmile",
29-
"repo": "PicList",
30-
"releaseType": "draft"
31-
}
32-
],
3317
"dmg": {
3418
"sign": false,
3519
"contents": [

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@
3535
"postinstall": "electron-builder install-app-deps",
3636
"postuninstall": "electron-builder install-app-deps",
3737
"prebuild": "electron-vite build",
38-
"prepare": "node ./scripts/prepare.js --all",
39-
"prepare:7zaip": "node ./scripts/prepare.js --type=7zip",
40-
"prepare:themes": "node ./scripts/prepare.js --type=themes",
38+
"prepare": "node ./scripts/prepare.js --type=themes",
39+
"prepare:7za": "node ./scripts/prepare.js --type=7zip",
4140
"preview": "electron-vite preview",
42-
"release": "electron-vite build && electron-builder",
43-
"sha256": "node ./scripts/gen-sha256.js",
4441
"test": "vitest",
4542
"winget": "node ./scripts/auto-winget.js"
4643
},

scripts/combine-yml.cjs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@ function main() {
9999
fs.mkdirSync(outputDir, { recursive: true })
100100
}
101101

102-
const windowsX64Ymls = findYmlInFolder(distPath, 'windows-x64-yml', 'latest.yml')
103-
const windowsArm64Ymls = findYmlInFolder(distPath, 'windows-arm64-yml', 'latest.yml')
104-
const macX64Ymls = findYmlInFolder(distPath, 'macos-x64-yml', 'latest-mac.yml')
105-
const macArm64Ymls = findYmlInFolder(distPath, 'macos-arm64-yml', 'latest-mac.yml')
106-
const linuxX64Ymls = findYmlInFolder(distPath, 'linux-x64-yml', 'latest-linux.yml')
107-
const linuxArm64Ymls = findYmlInFolder(distPath, 'linux-arm64-yml', 'latest-linux-arm64.yml')
108-
109-
console.log('\nFound yml files:')
110-
console.log(`Windows x64: ${windowsX64Ymls.map(f => path.basename(path.dirname(f))).join(', ')}`)
111-
console.log(`Windows ARM64: ${windowsArm64Ymls.map(f => path.basename(path.dirname(f))).join(', ')}`)
112-
console.log(`macOS x64: ${macX64Ymls.map(f => path.basename(path.dirname(f))).join(', ')}`)
113-
console.log(`macOS ARM64: ${macArm64Ymls.map(f => path.basename(path.dirname(f))).join(', ')}`)
114-
console.log(`Linux x64: ${linuxX64Ymls.map(f => path.basename(path.dirname(f))).join(', ')}`)
115-
console.log(`Linux ARM64: ${linuxArm64Ymls.map(f => path.basename(path.dirname(f))).join(', ')}`)
102+
const windowsX64Ymls = findYmlInFolder(distPath, 'windows-latest-x64-nsis-yml', 'latest.yml')
103+
const windowsArm64Ymls = findYmlInFolder(distPath, 'windows-11-arm-arm64-nsis-yml', 'latest.yml')
104+
const macX64Ymls = findYmlInFolder(distPath, 'macos-15-intel-x64-dmg-yml', 'latest-mac.yml')
105+
const macArm64Ymls = findYmlInFolder(distPath, 'macos-latest-arm64-dmg-yml', 'latest-mac.yml')
106+
const linuxX64AppImageYmls = findYmlInFolder(distPath, 'ubuntu-latest-x64-AppImage-yml', 'latest-linux.yml')
107+
const linuxArm64AppImageYmls = findYmlInFolder(
108+
distPath,
109+
'ubuntu-24.04-arm-arm64-AppImage-yml',
110+
'latest-linux-arm64.yml',
111+
)
112+
const linuxX64DebYmls = findYmlInFolder(distPath, 'ubuntu-latest-x64-deb-yml', 'latest-linux.yml')
113+
const linuxArm64DebYmls = findYmlInFolder(distPath, 'ubuntu-24.04-arm-arm64-deb-yml', 'latest-linux-arm64.yml')
114+
const linuxX64RpmYmls = findYmlInFolder(distPath, 'ubuntu-latest-x64-rpm-yml', 'latest-linux.yml')
115+
const linuxArm64RpmYmls = findYmlInFolder(distPath, 'ubuntu-24.04-arm-arm64-rpm-yml', 'latest-linux-arm64.yml')
116116

117117
const windowsYmls = [...windowsX64Ymls, ...windowsArm64Ymls]
118118
if (windowsYmls.length > 0) {
@@ -129,17 +129,20 @@ function main() {
129129
} else {
130130
console.log('\nNo macOS yml files found to combine')
131131
}
132+
const linuxX64Ymls = [...linuxX64AppImageYmls, ...linuxX64DebYmls, ...linuxX64RpmYmls]
132133
if (linuxX64Ymls.length > 0) {
133-
console.log('\nProcessing Linux x64 yml file (deduplicate only)...')
134-
processSingleYmlFile(linuxX64Ymls[0], path.join(outputDir, 'latest-linux.yml'))
134+
console.log(`\nCombining ${linuxX64Ymls.length} Linux x64 yml files...`)
135+
combineYmlFiles(linuxX64Ymls, path.join(outputDir, 'latest-linux.yml'))
135136
} else {
136-
console.log('\nNo Linux x64 yml files found')
137+
console.log('\nNo Linux x64 yml files found to combine')
137138
}
139+
140+
const linuxArm64Ymls = [...linuxArm64AppImageYmls, ...linuxArm64DebYmls, ...linuxArm64RpmYmls]
138141
if (linuxArm64Ymls.length > 0) {
139-
console.log('\nProcessing Linux ARM64 yml file (deduplicate only)...')
140-
processSingleYmlFile(linuxArm64Ymls[0], path.join(outputDir, 'latest-linux-arm64.yml'))
142+
console.log(`\nCombining ${linuxArm64Ymls.length} Linux arm64 yml files...`)
143+
combineYmlFiles(linuxArm64Ymls, path.join(outputDir, 'latest-linux-arm64.yml'))
141144
} else {
142-
console.log('\nNo Linux ARM64 yml files found')
145+
console.log('\nNo Linux arm64 yml files found to combine')
143146
}
144147

145148
console.log('\nYML combination and deduplication complete!')

scripts/config.js

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// different platform has different format
2+
import pkg from '../package.json' with { type: 'json' }
3+
4+
const version = pkg.version
25

36
// macos
47
const darwin = [
@@ -27,25 +30,36 @@ const linux = [
2730
appNameWithPrefix: 'PicList-',
2831
ext: '.AppImage',
2932
arch: '-arm64',
30-
'version-file': 'latest-linux.yml',
33+
'version-file': 'latest-linux-arm64.yml',
3134
},
3235
{
3336
appNameWithPrefix: 'PicList-',
34-
ext: '.snap',
37+
ext: '.deb',
3538
arch: '-amd64',
3639
'version-file': 'latest-linux.yml',
3740
},
3841
{
3942
appNameWithPrefix: 'PicList-',
4043
ext: '.deb',
41-
arch: '-amd64',
44+
arch: '-arm64',
45+
'version-file': 'latest-linux-arm64.yml',
46+
},
47+
{
48+
appNameWithPrefix: 'PicList-',
49+
ext: '.rpm',
50+
arch: '-x86_64',
4251
'version-file': 'latest-linux.yml',
4352
},
4453
{
4554
appNameWithPrefix: 'PicList-',
46-
ext: '.deb',
55+
ext: '.rpm',
4756
arch: '-arm64',
48-
'version-file': 'latest-linux.yml',
57+
'version-file': 'latest-linux-arm64.yml',
58+
},
59+
{
60+
appNameWithPrefix: 'PicList-',
61+
ext: '.snap',
62+
arch: '-amd64',
4963
},
5064
]
5165

@@ -54,29 +68,45 @@ const win32 = [
5468
{
5569
appNameWithPrefix: 'PicList-Setup-',
5670
ext: '.exe',
57-
arch: '-ia32',
71+
arch: '-x64',
5872
'version-file': 'latest.yml',
5973
},
6074
{
6175
appNameWithPrefix: 'PicList-Setup-',
6276
ext: '.exe',
63-
arch: '-x64',
77+
arch: '-arm64',
6478
'version-file': 'latest.yml',
6579
},
6680
{
6781
appNameWithPrefix: 'PicList-Setup-',
68-
ext: '.exe',
69-
arch: '', // 32 & 64
70-
'version-file': 'latest.yml',
82+
ext: '.zip',
83+
arch: '-x64-portable',
7184
},
7285
{
7386
appNameWithPrefix: 'PicList-Setup-',
74-
ext: '.exe',
75-
arch: '-arm64',
76-
'version-file': 'latest.yml',
87+
ext: '.zip',
88+
arch: '-arm64-portable',
89+
},
90+
{
91+
appNameWithPrefix: 'PicList-Setup-',
92+
ext: '.7z',
93+
arch: '-x64-portable',
94+
},
95+
{
96+
appNameWithPrefix: 'PicList-Setup-',
97+
ext: '.7z',
98+
arch: '-arm64-portable',
7799
},
78100
]
79101

102+
export const generateFileName = (platformConfig, version) => {
103+
return `${platformConfig.appNameWithPrefix}${version}${platformConfig.arch}${platformConfig.ext}`
104+
}
105+
106+
export const fileList = [...darwin, ...linux, ...win32].map(platformConfig => {
107+
return generateFileName(platformConfig, version)
108+
})
109+
80110
export default {
81111
darwin,
82112
linux,

0 commit comments

Comments
 (0)