Skip to content

Commit

Permalink
fix: add workflow to check version match with package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
m1911star committed May 17, 2023
1 parent d6804bb commit 084da7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/nightly-build.yml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-desktop-app.yml
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion apps/electron/scripts/generate-assets.mjs
Expand Up @@ -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,
Expand All @@ -19,9 +20,20 @@ console.log('build with following dir', {
publicAffineOutDir,
});

// step 0: check version match
const electronPackageJson = await fs.readFile(
path.join(electronRootDir, 'package.json'),
'utf-8'
);
const { version } = JSON.parse(electronPackageJson);
if (releaseVersionEnv && version !== releaseVersionEnv) {
throw new Error(
`Version mismatch, expected ${releaseVersionEnv} but got ${version}`
);
}
// copy web dist files to electron dist

// step 0: clean up
// step 1: clean up
await cleanup();
echo('Clean up done');

Expand Down

0 comments on commit 084da7a

Please sign in to comment.