Skip to content

Commit d21fb62

Browse files
committed
refactor release process
1 parent 7e1fe31 commit d21fb62

26 files changed

+164
-249
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ To test the build scripts locally:
175175
bun run scripts/github-actions/build-platform-binary.ts --platform linux --version 2.23.0-test
176176

177177
# Test version determination
178-
bun run scripts/release/utils/get-version.ts --version 2.23.0-test
178+
bun run scripts/release/get-version.ts --version 2.23.0-test
179179

180180
# Test npm publish with provenance (requires trusted publisher setup)
181181
cd __release-npm

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464

6565
- name: Build binary for ${{ matrix.platform }}
6666
if: matrix.platform != 'alpine'
67-
run: bun run scripts/github-actions/build-platform-binary.ts --platform ${{ matrix.platform }} --version ${{ inputs.version }}
67+
run: bun run scripts/build-dist-package.ts --platform ${{ matrix.platform }} --version ${{ inputs.version }}
6868

6969
- name: Build Alpine binary (in Docker)
7070
if: matrix.platform == 'alpine'
@@ -74,7 +74,7 @@ jobs:
7474
curl -fsSL https://bun.sh/install | bash
7575
export PATH=\$HOME/.bun/bin:\$PATH
7676
bun install
77-
bun run scripts/github-actions/build-platform-binary.ts --platform alpine --version ${{ inputs.version }}
77+
bun run scripts/build-dist-package.ts --platform alpine --version ${{ inputs.version }}
7878
"
7979
8080
- name: Upload binary artifact

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"**/node_modules": true,
2323
"**/bower_components": true,
2424
"**/*.code-search": true,
25-
"**/__dev-bin/**/*": true,
26-
"user-projects/**/*": true
25+
"**/__dev-bin/**/*": true
2726
},
2827
"java.configuration.updateBuildConfiguration": "automatic",
2928
"python.formatting.provider": "autopep8",

_configs/lambdas/throwing.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { Handler } from 'aws-lambda';
2+
3+
export default (event, context): Handler => {
4+
console.log(event, context);
5+
throw new Error('This is a test error');
6+
};

_configs/simple-lambda.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineConfig, LambdaFunction, StacktapeLambdaBuildpackPackaging } from '../__release-npm';
2+
3+
export default defineConfig(() => {
4+
const lambda = new LambdaFunction('simple-lambda', {
5+
packaging: new StacktapeLambdaBuildpackPackaging({
6+
entryfilePath: './lambdas/throwing.ts'
7+
}),
8+
url: {
9+
enabled: true,
10+
cors: {
11+
enabled: true
12+
}
13+
}
14+
});
15+
16+
return {
17+
resources: { lambda }
18+
};
19+
});

bun.lockb

-103 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dev": "bun run scripts/dev.ts",
1313
"lint": "bunx eslint ./src ./shared ./scripts ./helper-lambdas --fix",
1414
"test": "bun test ./src/**/*.spec.ts ./shared/**/*.spec.ts",
15-
"build:cli:src": "bun scripts/build-cli-sources.ts",
15+
"build": "bun scripts/build-everything.ts",
1616
"build:npm": "bun --max_old_space_size=32768 scripts/build-npm.ts",
1717
"build:npm:sdk": "bun --max_old_space_size=32768 scripts/build-npm-sdk.ts",
1818
"build:npm:main": "bun --max_old_space_size=32768 scripts/build-npm-main-export.ts",

scripts/build-dist-package.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { join } from 'node:path';
2+
import { BIN_DIST_FOLDER_PATH } from '@shared/naming/project-fs-paths';
3+
import { getPlatform } from '@shared/utils/bin-executable';
4+
import { logInfo, logSuccess } from '@shared/utils/logging';
5+
import { archiveItem } from '@shared/utils/zip';
6+
import { remove } from 'fs-extra';
7+
import yargsParser from 'yargs-parser';
8+
import { generateStarterProjectsMetadata } from './generate-starter-projects-metadata';
9+
import { packageHelperLambdas } from './package-helper-lambdas';
10+
import { getCliArgs } from './release/args';
11+
import {
12+
buildBinaryFile,
13+
buildEsbuildRegister,
14+
copyConfigSchema,
15+
copyEsbuildBinary,
16+
copyNixpacksBinary,
17+
copyPackBinary,
18+
copySessionsManagerPluginBinary,
19+
createReleaseDataFile,
20+
EXECUTABLE_FILE_PATTERNS,
21+
generateSourceMapInstall
22+
} from './release/build-cli-sources';
23+
24+
const { debug, keepUnarchived } = getCliArgs();
25+
26+
const buildEverything = async () => {
27+
const argv = yargsParser(process.argv.slice(2));
28+
const platform = (argv.platform as SupportedPlatform) || getPlatform();
29+
const version = (argv.version as string) || 'dev';
30+
31+
if (!platform || !version) {
32+
throw new Error('Platform and version are required. Usage: --platform <platform> --version <version>');
33+
}
34+
35+
logInfo(`Building binary for platform: ${platform}, version: ${version}`);
36+
37+
const distFolderPath = BIN_DIST_FOLDER_PATH;
38+
await remove(distFolderPath);
39+
40+
const platformDistFolderPath = await buildBinaryFile({
41+
distFolderPath,
42+
platform,
43+
debug,
44+
version
45+
});
46+
47+
await Promise.all([
48+
copyPackBinary({ distFolderPath, platform }),
49+
copyNixpacksBinary({ distFolderPath, platform }),
50+
copySessionsManagerPluginBinary({ distFolderPath, platform }),
51+
copyEsbuildBinary({ distFolderPath, platform }),
52+
buildEsbuildRegister({ distFolderPath: platformDistFolderPath }),
53+
copyConfigSchema({ distFolderPath: platformDistFolderPath }),
54+
generateStarterProjectsMetadata({ distFolderPath: platformDistFolderPath }),
55+
packageHelperLambdas({ isDev: false, distFolderPath: platformDistFolderPath }),
56+
createReleaseDataFile({ distFolderPath: platformDistFolderPath, version }),
57+
generateSourceMapInstall({ distFolderPath: platformDistFolderPath })
58+
]);
59+
// await copyLegalComments({ distFolderPath: platformDistFolderPath });
60+
61+
// Archive the binary
62+
const archivePath = await archiveItem({
63+
absoluteSourcePath: platformDistFolderPath,
64+
format: platform === 'win' ? 'zip' : 'tgz',
65+
executablePatterns: EXECUTABLE_FILE_PATTERNS
66+
});
67+
68+
if (!keepUnarchived) {
69+
logInfo('Cleaning up temporary files...');
70+
await Promise.all([remove(platformDistFolderPath), remove(join(platformDistFolderPath, 'downloaded'))]);
71+
logSuccess('Temporary files cleaned up successfully.');
72+
}
73+
74+
logSuccess(`Binary for platform ${platform} built successfully: ${archivePath}`);
75+
};
76+
77+
if (import.meta.main) {
78+
buildEverything().catch((error) => {
79+
console.error('Error building platform binary:', error);
80+
process.exit(1);
81+
});
82+
}

scripts/build-npm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { logInfo, logSuccess } from '../shared/utils/logging';
55
import { buildNpmMainExport } from './build-npm-main-export';
66
import { buildNpmSdkExport } from './build-npm-sdk-export.js';
77
import { packageHelperLambdas } from './package-helper-lambdas.js';
8-
import { getVersion } from './release/utils/args';
8+
import { getVersion } from './release/args';
99

1010
export const copySdkPackageJson = async (version?: string) => {
1111
const packageJson = await readJson(NPM_PACKAGE_JSON_SOURCE_PATH);

scripts/dev.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CLI_DIST_PATH, CLI_SOURCE_PATH, DIST_FOLDER_PATH } from '@shared/naming
22
import { dynamicRequire } from '@shared/utils/fs-utils';
33
import { logError, logInfo, logWarn } from '@shared/utils/logging';
44
import packageJson from '../package.json';
5+
import { generateSourceMapInstall } from './build-cli-sources';
56
import { packageHelperLambdas } from './package-helper-lambdas';
67

78
const buildSource = async () => {
@@ -22,7 +23,11 @@ const buildSource = async () => {
2223
};
2324

2425
export const runDev = async () => {
25-
await Promise.all([buildSource(), packageHelperLambdas({ isDev: true, distFolderPath: DIST_FOLDER_PATH })]);
26+
await Promise.all([
27+
buildSource(),
28+
packageHelperLambdas({ isDev: true, distFolderPath: DIST_FOLDER_PATH }),
29+
generateSourceMapInstall({ distFolderPath: DIST_FOLDER_PATH })
30+
]);
2631

2732
logInfo('----- RUN -----');
2833
try {

0 commit comments

Comments
 (0)