Skip to content

Commit

Permalink
add self host zip publishing with release
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Mar 3, 2025
1 parent 2a8f514 commit 874cafc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-zip.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Bundle
name: Make Self Host Zip

on:
workflow_dispatch:
Expand Down Expand Up @@ -26,18 +26,18 @@ jobs:

- name: Bundle server.js
run: |
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js --define=process.env.NODE_ENV="production"
- name: Create distribution package
run: |
mkdir -p package
cp -r dist package/
cp bundled-server.js package/server.js
cd package
zip -r ../dist-package.zip .
zip -r ../self-host.zip .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dist-package
path: dist-package.zip
name: self-host
path: self-host.zip
29 changes: 23 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,36 @@ jobs:
with:
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
id: deploy
# publish to github
- run: cp vercel.json .vercel/output/static/vercel.json
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .vercel/output/static
force_orphan: true

- name: Build self-host version
run: pnpm build
- name: Bundle server.js
run: |
pnpm esbuild server.js --bundle --platform=node --outfile=bundled-server.js --define=process.env.NODE_ENV="production"
- name: Create zip package
run: |
mkdir -p package
cp -r dist package/
cp bundled-server.js package/server.js
cd package
zip -r ../self-host.zip .
- run: |
pnpx zardoy-release node --footer "This release URL: ${{ steps.deploy.outputs.stdout }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# has possible output: tag
id: release
# has output
- run: cp vercel.json .vercel/output/static/vercel.json
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .vercel/output/static
force_orphan: true
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"web",
"client"
],
"release": {
"attachReleaseFiles": "self-host.zip"
},
"publish": {
"preset": {
"publishOnlyIfChanged": true,
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try {
// Create our app
const app = express()

const isProd = process.argv.includes('--prod')
const isProd = process.argv.includes('--prod') || process.env.NODE_ENV === 'production'
app.use(compression())
app.use(cors())
app.use(netApi({ allowOrigin: '*' }))
Expand Down

0 comments on commit 874cafc

Please sign in to comment.