build: separated github and forgejo build workflows
This commit is contained in:
parent
d79738a2f1
commit
a72213ac73
3 changed files with 64 additions and 50 deletions
49
.forgejo/workflows/build.yml
Normal file
49
.forgejo/workflows/build.yml
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
name: Build and Upload Canary
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: node:20
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# 1. FIX: Install system dependencies BEFORE setup-bun
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y unzip libstdc++6 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libasound2
|
||||||
|
|
||||||
|
- name: Manual Bun Install
|
||||||
|
run: |
|
||||||
|
# Download and install via official script
|
||||||
|
curl -fsSL https://bun.sh/install | bash
|
||||||
|
|
||||||
|
# Manually add Bun to the PATH for subsequent steps
|
||||||
|
echo "BUN_INSTALL=$HOME/.bun" >> $GITHUB_ENV
|
||||||
|
echo "$HOME/.bun/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
# Force execution permissions just in case
|
||||||
|
chmod +x $HOME/.bun/bin/bun
|
||||||
|
|
||||||
|
# Verify it works immediately
|
||||||
|
$HOME/.bun/bin/bun --version
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Build Canary
|
||||||
|
run: bun run package:auto-prod
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: canary-build
|
||||||
|
path: build/linux
|
||||||
|
retention-days: 7
|
||||||
26
.github/workflows/build.yml
vendored
26
.github/workflows/build.yml
vendored
|
|
@ -7,7 +7,10 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest, ubuntu-latest]
|
||||||
container:
|
container:
|
||||||
image: node:20
|
image: node:20
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -20,30 +23,19 @@ jobs:
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y unzip libstdc++6 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libasound2
|
apt-get install -y unzip libstdc++6 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libasound2
|
||||||
|
|
||||||
- name: Manual Bun Install
|
- name: Bun Install
|
||||||
run: |
|
uses: oven-sh/setup-bun@v2
|
||||||
# Download and install via official script
|
|
||||||
curl -fsSL https://bun.sh/install | bash
|
|
||||||
|
|
||||||
# Manually add Bun to the PATH for subsequent steps
|
|
||||||
echo "BUN_INSTALL=$HOME/.bun" >> $GITHUB_ENV
|
|
||||||
echo "$HOME/.bun/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
# Force execution permissions just in case
|
|
||||||
chmod +x $HOME/.bun/bin/bun
|
|
||||||
|
|
||||||
# Verify it works immediately
|
|
||||||
$HOME/.bun/bin/bun --version
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build Canary
|
- name: Build Canary
|
||||||
run: bun run package:auto-prod
|
run: bun run package:auto-prod
|
||||||
|
env:
|
||||||
|
BUILD_DIR: ./build/${{ runner.os }}
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: canary-build
|
name: canary-build
|
||||||
path: build/
|
path: build/${{ runner.os }}
|
||||||
retention-days: 7
|
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,8 @@
|
||||||
import { PluginBuilder } from "bun";
|
|
||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path, { resolve, sep } from "node:path";
|
import path, { } from "node:path";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import appPackage from '../package.json';
|
|
||||||
|
|
||||||
const plugin = {
|
const buildSubDir = process.env.BUILD_DIR ?? `./build/${os.platform()}`;
|
||||||
name: "dist-absolute-filter",
|
|
||||||
setup (build: PluginBuilder)
|
|
||||||
{
|
|
||||||
build.onStart(async () =>
|
|
||||||
{
|
|
||||||
if (await fs.exists('./build'))
|
|
||||||
{
|
|
||||||
await fs.rm('./build', { recursive: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 1. Intercept all resolutions to check their REAL path
|
|
||||||
build.onResolve({ filter: /.*/, namespace: 'file' }, (args) =>
|
|
||||||
{
|
|
||||||
if (args.path.startsWith(`.${sep}dist`))
|
|
||||||
{
|
|
||||||
return { path: resolve(args.resolveDir, args.path), namespace: "dist_assets" };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
build.onLoad({ filter: /.*/, namespace: 'dist_assets' }, async (args) =>
|
|
||||||
{
|
|
||||||
console.log(args.path);
|
|
||||||
return { contents: await Bun.file(args.path).bytes(), loader: 'file' };
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const compileOption: Bun.CompileBuildOptions = {
|
const compileOption: Bun.CompileBuildOptions = {
|
||||||
outfile: "gameflow",
|
outfile: "gameflow",
|
||||||
|
|
@ -49,7 +22,7 @@ await Bun.build({
|
||||||
entrypoints: ["./src/bun/index.ts", "./src/bun/webview-worker.ts"],
|
entrypoints: ["./src/bun/index.ts", "./src/bun/webview-worker.ts"],
|
||||||
metafile: true,
|
metafile: true,
|
||||||
compile: compileOption,
|
compile: compileOption,
|
||||||
outdir: `./build/${os.platform()}`,
|
outdir: buildSubDir,
|
||||||
root: './src/bun',
|
root: './src/bun',
|
||||||
define: {
|
define: {
|
||||||
"process.env.IS_BINARY": "true"
|
"process.env.IS_BINARY": "true"
|
||||||
|
|
@ -67,9 +40,9 @@ await Bun.build({
|
||||||
{
|
{
|
||||||
build.onStart(async () =>
|
build.onStart(async () =>
|
||||||
{
|
{
|
||||||
if (await fs.exists(`./build/${os.platform()}`))
|
if (await fs.exists(buildSubDir))
|
||||||
{
|
{
|
||||||
const files = await fs.readdir(`./build/${os.platform()}`, { withFileTypes: true });
|
const files = await fs.readdir(buildSubDir, { withFileTypes: true });
|
||||||
for (const file of files)
|
for (const file of files)
|
||||||
{
|
{
|
||||||
await fs.rm(path.join(file.parentPath, file.name), { recursive: true });
|
await fs.rm(path.join(file.parentPath, file.name), { recursive: true });
|
||||||
|
|
@ -78,7 +51,7 @@ await Bun.build({
|
||||||
});
|
});
|
||||||
build.onEnd(async () =>
|
build.onEnd(async () =>
|
||||||
{
|
{
|
||||||
await fs.cp('./dist', `./build/${os.platform()}/dist`, { recursive: true });
|
await fs.cp('./dist', `${buildSubDir}/dist`, { recursive: true });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue