Skip to content

Commit

Permalink
feat: docker build in release
Browse files Browse the repository at this point in the history
  • Loading branch information
cgawron committed Sep 11, 2023
1 parent 7695b58 commit 4f05ee3
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
8 changes: 7 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.1",
"common": "1.0.0",
"common": "workspace:*",
"concurrently": "^8.2.1",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
Expand Down Expand Up @@ -75,6 +75,12 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "yarn exec node utility/patch-workspace-versions.js"
}
],
"@semantic-release/git",
"@semantic-release/github"
]
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@testing-library/user-event": "^13.2.1",
"@types/react": "^18.2.21",
"axios": "^1.5.0",
"common": "workspace:^",
"common": "workspace:*",
"date-fns": "^2.30.0",
"i18next": "^23.4.6",
"i18next-browser-languagedetector": "^7.1.0",
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "yarn exec node utility/patch-workspace-versions.js"
}
],
"@semantic-release/git",
"@semantic-release/github"
],
Expand Down
44 changes: 44 additions & 0 deletions utility/patch-workspace-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// loop over packages, get versions and names
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
const root = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
const packages = {};

// Create a version map
let versionMap = Object.assign(
{},
...root.workspaces.map((packageDir) => {
const packageInfo = JSON.parse(
fs.readFileSync(`${packageDir}/package.json`, 'utf8'),
);

packages[packageDir] = packageInfo;
return { [packageInfo.name]: packageInfo.version };
}),
);

// Loop over and patch versions
Object.entries(packages).forEach(([packageDir, packageInfo]) => {
if (packageInfo.dependencies) {
packageInfo.dependencies = Object.assign(
packageInfo.dependencies,
...Object.entries(packageInfo.dependencies).map(([name, version]) => ({
[name]: versionMap[name] ? `workspace:*` : version,
})),
);
}

if (packageInfo.devDependencies) {
packageInfo.devDependencies = Object.assign(
packageInfo.devDependencies,
...Object.entries(packageInfo.devDependencies).map(([name, version]) => ({
[name]: versionMap[name] ? `workspace:*` : version,
})),
);
}

fs.writeFileSync(
`${packageDir}/package.json`,
JSON.stringify(packageInfo, undefined, 2) + '\n',
);
});
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7660,7 +7660,7 @@ __metadata:
"@types/react": "npm:^18.2.21"
"@types/react-router-dom": "npm:^5.3.3"
axios: "npm:^1.5.0"
common: "workspace:^"
common: "workspace:*"
cypress: "npm:^13.1.0"
date-fns: "npm:^2.30.0"
dotenv-cli: "npm:^4.0.0"
Expand Down Expand Up @@ -7964,7 +7964,7 @@ __metadata:
languageName: node
linkType: hard

"common@workspace:*, common@workspace:^, common@workspace:common":
"common@workspace:*, common@workspace:common":
version: 0.0.0-use.local
resolution: "common@workspace:common"
dependencies:
Expand Down

0 comments on commit 4f05ee3

Please sign in to comment.