fix: add workflow to check release version match with package.json (#2420)

This commit is contained in:
Horus 2023-05-18 01:37:28 +08:00 committed by GitHub
parent c870104370
commit 02e1f528bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -66,6 +66,7 @@ jobs:
API_SERVER_PROFILE: prod
ENABLE_TEST_PROPERTIES: false
ENABLE_IMAGE_PREVIEW_MODAL: false
RELEASE_VERSION: ${{ needs.set-build-version.outputs.version }}
- name: Upload Artifact (web-static)
uses: actions/upload-artifact@v3

View File

@ -67,6 +67,7 @@ jobs:
API_SERVER_PROFILE: prod
ENABLE_TEST_PROPERTIES: false
ENABLE_IMAGE_PREVIEW_MODAL: false
RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: Upload Artifact (web-static)
uses: actions/upload-artifact@v3

View File

@ -9,6 +9,7 @@ const publicDistDir = path.join(electronRootDir, 'resources');
const affineWebDir = path.join(repoRootDir, 'apps', 'web');
const affineWebOutDir = path.join(affineWebDir, 'out');
const publicAffineOutDir = path.join(publicDistDir, `web-static`);
const releaseVersionEnv = process.env.RELEASE_VERSION || '';
console.log('build with following dir', {
repoRootDir,
@ -19,9 +20,20 @@ console.log('build with following dir', {
publicAffineOutDir,
});
// step 0: check version match
const electronPackageJson = await import(`${electronRootDir}/package.json`, {
assert: {
type: 'json',
},
});
if (releaseVersionEnv && electronPackageJson.version !== releaseVersionEnv) {
throw new Error(
`Version mismatch, expected ${releaseVersionEnv} but got ${electronPackageJson.version}`
);
}
// copy web dist files to electron dist
// step 0: clean up
// step 1: clean up
await cleanup();
echo('Clean up done');