Skip to content

Commit ad78601

Browse files
committed
feat(ci): support to run release-tamagotchi.yml workflow for deb and rpm files
1 parent 32934b9 commit ad78601

File tree

7 files changed

+281
-169
lines changed

7 files changed

+281
-169
lines changed

.github/workflows/release-tamagotchi.yml

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ permissions:
44
contents: write
55

66
env:
7-
PRODUCT_NAME: 'AIRI'
87
BUNDLE_NAME: ''
8+
PRODUCT_NAME: 'AIRI'
9+
VERSION: ''
910

1011
on:
1112
release:
@@ -40,32 +41,32 @@ jobs:
4041
- os: macos-13
4142
artifact: darwin-x64
4243
target: x86_64-apple-darwin
44+
arch: x64
4345
builder-args: --macos --x64
44-
ext: dmg
4546

4647
- os: macos-latest
4748
artifact: darwin-arm64
4849
target: aarch64-apple-darwin
4950
builder-args: --macos --arm64
50-
ext: dmg
51+
arch: arm64
5152

5253
- os: ubuntu-latest
5354
artifact: linux-x64
5455
target: x86_64-unknown-linux-gnu
5556
builder-args: --linux --x64
56-
ext: AppImage
57+
arch: x64
5758

5859
- os: ubuntu-24.04-arm
5960
artifact: linux-arm64
6061
target: aarch64-unknown-linux-gnu
6162
builder-args: --linux --arm64
62-
ext: AppImage
63+
arch: arm64
6364

6465
- os: windows-latest
6566
artifact: windows-x64-setup
6667
target: x86_64-pc-windows-msvc
6768
builder-args: --windows --x64
68-
ext: exe
69+
arch: x64
6970

7071
runs-on: ${{ matrix.os }}
7172
steps:
@@ -108,58 +109,95 @@ jobs:
108109
# ---------
109110
# Nightly (schedule) builds only
110111
# ---------
111-
- name: Get Name of Artifacts (Nightly + Windows Only)
112+
113+
- name: Get Artifacts Envs (Nightly + Windows Only)
112114
if: ${{ github.event_name == 'schedule' && matrix.os == 'windows-latest' }}
113115
run: |
114-
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name
115-
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
116+
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name)" >> $env:GITHUB_ENV
117+
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version)" >> $env:GITHUB_ENV
116118
117-
- name: Get Name of Artifacts (Nightly)
119+
- name: Get Artifacts Envs (Nightly + Non-Windows)
118120
if: ${{ github.event_name == 'schedule' && matrix.os != 'windows-latest' }}
119121
run: |
120-
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name
121-
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
122+
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version)" >> $GITHUB_ENV
123+
124+
- name: Get Artifacts Envs (Nightly + macOS Only)
125+
if: ${{ github.event_name == 'schedule' && (matrix.os == 'macos-latest' || matrix.os == 'macos-13') }}
126+
run: |
127+
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name)" >> $GITHUB_ENV
122128
123129
- name: Rename Artifacts (Nightly)
124130
if: ${{ github.event_name == 'schedule' }}
125131
run:
126132
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }}
127133

128-
- name: Upload Artifacts (Nightly)
129-
if: ${{ github.event_name == 'schedule' }}
134+
- name: Upload Artifacts (Nightly + Non-Linux)
135+
if: ${{ github.event_name == 'schedule' && (matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-24.04-arm') }}
130136
uses: actions/upload-artifact@v4
131137
with:
132138
name: ${{ env.BUNDLE_NAME }}
133139
path: apps/stage-tamagotchi/bundle/${{ env.BUNDLE_NAME }}
134140

135-
# ---------
136-
# Workflow Dispatch only
137-
# ---------
141+
- name: Upload Artifacts (Nightly + Linux deb)
142+
if: ${{ github.event_name == 'schedule' && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
146+
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
147+
148+
- name: Upload Artifacts (Nightly + Linux rpm)
149+
if: ${{ github.event_name == 'schedule' && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
150+
uses: actions/upload-artifact@v4
151+
with:
152+
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
153+
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
154+
155+
# ---------
156+
# Workflow Dispatch only
157+
# ---------
138158

139-
- name: Get Name of Artifacts (Manual + Windows Only)
159+
- name: Get Artifacts Envs (Manual + Windows Only)
140160
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os == 'windows-latest' }}
141161
run: |
142-
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
143-
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
162+
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $env:GITHUB_ENV
163+
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $env:GITHUB_ENV
144164
145-
- name: Get Name of Artifacts (Manual)
165+
- name: Get Artifacts Envs (Manual + Non-Windows)
146166
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os != 'windows-latest' }}
147167
run: |
148-
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
149-
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
168+
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
169+
170+
- name: Get Artifacts Envs (Manual + macOS Only)
171+
if: ${{ github.event_name == 'workflow_dispatch' && (matrix.os == 'macos-latest' || matrix.os == 'macos-13') }}
172+
run: |
173+
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
150174
151175
- name: Rename Artifacts (Manual)
152176
if: ${{ github.event_name == 'workflow_dispatch' }}
153177
run: |
154178
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }} --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
155179
156-
- name: Upload Artifacts (Manual + Non-Release)
157-
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only }}
180+
- name: Upload Artifacts (Manual + Non-Release + Non-Linux)
181+
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-24.04-arm') }}
158182
uses: actions/upload-artifact@v4
159183
with:
160184
name: ${{ env.BUNDLE_NAME }}
161185
path: apps/stage-tamagotchi/bundle/${{ env.BUNDLE_NAME }}
162186

187+
- name: Upload Artifacts (Manual + Non-Release + Linux deb)
188+
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
189+
uses: actions/upload-artifact@v4
190+
with:
191+
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
192+
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
193+
194+
- name: Upload Artifacts (Manual + Non-Release + Linux rpm)
195+
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
196+
uses: actions/upload-artifact@v4
197+
with:
198+
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
199+
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
200+
163201
- name: Upload To GitHub Releases (Manual + Overwrite Release)
164202
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && !inputs.artifacts_only }}
165203
uses: softprops/action-gh-release@v2

apps/stage-tamagotchi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"build:mac": "pnpm run build && electron-builder --mac",
2424
"build:linux": "pnpm run build && electron-builder --linux",
2525
"rename-artifacts": "mkdir -p bundle && tsx scripts/rename-artifacts.ts",
26-
"name-of-artifacts": "tsx scripts/name-of-artifacts.ts"
26+
"artifacts-metadata": "tsx scripts/artifacts-metadata.ts"
2727
},
2828
"dependencies": {
2929
"@date-fns/utc": "^2.1.1",
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import process from 'node:process'
2+
3+
import { cac } from 'cac'
4+
5+
import { getElectronBuilderConfig, getFilenames, getVersion } from './utils'
6+
7+
async function main() {
8+
const cli = cac('name-of-artifact')
9+
.option(
10+
'--release',
11+
'Rename with version from package.json',
12+
{ default: false },
13+
)
14+
.option(
15+
'--auto-tag',
16+
'Automatically tag the release with the latest git ref',
17+
{ default: false },
18+
)
19+
.option(
20+
'--tag <tag>',
21+
'Tag to use for the release',
22+
{ default: '', type: [String] },
23+
)
24+
.option(
25+
'--get-bundle-name',
26+
'Get the bundle name',
27+
{ default: false },
28+
)
29+
.option(
30+
'--get-product-name',
31+
'Get the product name',
32+
{ default: false },
33+
)
34+
.option(
35+
'--get-version',
36+
'Get the version',
37+
{ default: false },
38+
)
39+
40+
const args = cli.parse()
41+
42+
const argOptions = args.options as {
43+
release: boolean
44+
autoTag: boolean
45+
tag: string[]
46+
getBundleName: boolean
47+
getProductName: boolean
48+
getVersion: boolean
49+
}
50+
51+
const target = args.args[0]
52+
if (argOptions.getBundleName) {
53+
const filenames = await getFilenames(target, argOptions)
54+
console.info(filenames[0].releaseArtifactFilename)
55+
}
56+
if (argOptions.getProductName) {
57+
const electronBuilderConfig = await getElectronBuilderConfig()
58+
console.info(electronBuilderConfig.productName)
59+
}
60+
if (argOptions.getVersion) {
61+
const version = await getVersion({ release: argOptions.release, autoTag: argOptions.autoTag, tag: argOptions.tag })
62+
console.info(version)
63+
}
64+
}
65+
66+
main()
67+
.catch((error) => {
68+
console.error('Error during generating name:', error)
69+
process.exit(1)
70+
})

apps/stage-tamagotchi/scripts/name-of-artifacts.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

apps/stage-tamagotchi/scripts/rename-artifacts.ts

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { cac } from 'cac'
77

88
import packageJSON from '../package.json' assert { type: 'json' }
99

10-
import { getElectronBuilderConfig, getFilename, getVersion } from './utils'
10+
import { getElectronBuilderConfig, getFilenames, getVersion } from './utils'
1111

1212
async function main() {
1313
const cli = cac('rename-artifact')
@@ -66,39 +66,15 @@ async function main() {
6666

6767
mkdirSync(bundlePrefix, { recursive: true })
6868

69-
let renameFrom = ''
70-
let renameTo = ''
71-
const filename = await getFilename(target, argOptions)
72-
console.info(filename, 'is the target filename')
73-
74-
switch (target) {
75-
case 'x86_64-pc-windows-msvc':
76-
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-windows-x64-setup.exe`)
77-
renameTo = join(bundlePrefix, filename)
78-
break
79-
case 'x86_64-unknown-linux-gnu':
80-
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-linux-x86_64.AppImage`)
81-
renameTo = join(bundlePrefix, filename)
82-
break
83-
case 'aarch64-unknown-linux-gnu':
84-
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-linux-arm64.AppImage`)
85-
renameTo = join(bundlePrefix, filename)
86-
break
87-
case 'aarch64-apple-darwin':
88-
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-darwin-arm64.dmg`)
89-
renameTo = join(bundlePrefix, filename)
90-
break
91-
case 'x86_64-apple-darwin':
92-
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-darwin-x64.dmg`)
93-
renameTo = join(bundlePrefix, filename)
94-
break
95-
default:
96-
console.error('Target is not supported')
97-
process.exit(1)
98-
}
69+
const filenames = await getFilenames(target, argOptions)
70+
console.info(filenames, 'is the target filename')
9971

100-
console.info('renaming, from:', renameFrom, 'to:', renameTo)
101-
renameSync(renameFrom, renameTo)
72+
for (const filename of filenames) {
73+
const renameFrom = join(srcPrefix, filename.outputFilename)
74+
const renameTo = join(bundlePrefix, filename.releaseArtifactFilename)
75+
console.info('renaming, from:', renameFrom, 'to:', renameTo)
76+
renameSync(renameFrom, renameTo)
77+
}
10278
}
10379

10480
main()

0 commit comments

Comments
 (0)