Skip to content

Commit 874cafc

Browse files
committed
add self host zip publishing with release
1 parent 2a8f514 commit 874cafc

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

.github/workflows/build-zip.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Bundle
1+
name: Make Self Host Zip
22

33
on:
44
workflow_dispatch:
@@ -26,18 +26,18 @@ jobs:
2626

2727
- name: Bundle server.js
2828
run: |
29-
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js
29+
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js --define=process.env.NODE_ENV="production"
3030
3131
- name: Create distribution package
3232
run: |
3333
mkdir -p package
3434
cp -r dist package/
3535
cp bundled-server.js package/server.js
3636
cd package
37-
zip -r ../dist-package.zip .
37+
zip -r ../self-host.zip .
3838
3939
- name: Upload artifact
4040
uses: actions/upload-artifact@v4
4141
with:
42-
name: dist-package
43-
path: dist-package.zip
42+
name: self-host
43+
path: self-host.zip

.github/workflows/publish.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,36 @@ jobs:
4343
with:
4444
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
4545
id: deploy
46+
# publish to github
47+
- run: cp vercel.json .vercel/output/static/vercel.json
48+
- uses: peaceiris/actions-gh-pages@v3
49+
with:
50+
github_token: ${{ secrets.GITHUB_TOKEN }}
51+
publish_dir: .vercel/output/static
52+
force_orphan: true
53+
54+
- name: Build self-host version
55+
run: pnpm build
56+
- name: Bundle server.js
57+
run: |
58+
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js --define=process.env.NODE_ENV="production"
59+
60+
- name: Create zip package
61+
run: |
62+
mkdir -p package
63+
cp -r dist package/
64+
cp bundled-server.js package/server.js
65+
cd package
66+
zip -r ../self-host.zip .
67+
4668
- run: |
4769
pnpx zardoy-release node --footer "This release URL: ${{ steps.deploy.outputs.stdout }}"
4870
env:
4971
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5072
# has possible output: tag
5173
id: release
74+
5275
# has output
53-
- run: cp vercel.json .vercel/output/static/vercel.json
54-
- uses: peaceiris/actions-gh-pages@v3
55-
with:
56-
github_token: ${{ secrets.GITHUB_TOKEN }}
57-
publish_dir: .vercel/output/static
58-
force_orphan: true
5976
- name: Set publishing config
6077
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
6178
env:

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"web",
3636
"client"
3737
],
38+
"release": {
39+
"attachReleaseFiles": "self-host.zip"
40+
},
3841
"publish": {
3942
"preset": {
4043
"publishOnlyIfChanged": true,

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ try {
1515
// Create our app
1616
const app = express()
1717

18-
const isProd = process.argv.includes('--prod')
18+
const isProd = process.argv.includes('--prod') || process.env.NODE_ENV === 'production'
1919
app.use(compression())
2020
app.use(cors())
2121
app.use(netApi({ allowOrigin: '*' }))

0 commit comments

Comments
 (0)