This repository has been archived by the owner on Aug 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use new versioning script instead of lerna
- Loading branch information
ThomasAribart
committed
Jul 29, 2022
1 parent
59338a4
commit 128b717
Showing
7 changed files
with
360 additions
and
3,045 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 🚀 Release to NPM | ||
|
||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
build: | ||
name: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
- name: Install & cache node dependencies | ||
uses: ./.github/actions/install-node-deps | ||
- name: Build packages | ||
run: yarn package | ||
- name: Set packages versions | ||
run: yarn set-packages-versions $RELEASE_VERSION | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./packages/core/package.json | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./packages/dynamodb-event-storage-adapter/package.json | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./packages/inmemory-event-storage-adapter/package.json | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./packages/json-schema-event/package.json | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./packages/zod-event/package.json | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./packages/test-tools/package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { readdirSync, readFileSync, writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const newVersion = process.argv[2] as string | undefined; | ||
|
||
if (newVersion === undefined) { | ||
throw new Error('Invalid version'); | ||
} | ||
|
||
const semanticVersioningRegex = | ||
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; | ||
|
||
const VERSION_MAJOR = (newVersion.match(semanticVersioningRegex) ?? [])[1]; | ||
|
||
type PackageJson = { | ||
version?: string; | ||
dependencies?: Record<string, string>; | ||
devDependencies?: Record<string, string>; | ||
peerDependencies?: Record<string, string>; | ||
}; | ||
|
||
const packagesPath = join(__dirname, '..', 'packages'); | ||
const packagesNames = readdirSync(join(__dirname, '..', 'packages')); | ||
|
||
packagesNames.forEach(packageName => { | ||
const packageJsonPath = join(packagesPath, packageName, 'package.json'); | ||
|
||
const packageJson = JSON.parse( | ||
readFileSync(packageJsonPath).toString(), | ||
) as PackageJson; | ||
|
||
packageJson.version = newVersion; | ||
|
||
Object.keys(packageJson.dependencies ?? {}).forEach(dependencyName => { | ||
if (dependencyName.startsWith('@castore/')) { | ||
(packageJson.dependencies as Record<string, string>)[dependencyName] = | ||
newVersion; | ||
} | ||
}); | ||
|
||
Object.keys(packageJson.peerDependencies ?? {}).forEach(dependencyName => { | ||
if (dependencyName.startsWith('@castore/')) { | ||
(packageJson.peerDependencies as Record<string, string>)[ | ||
dependencyName | ||
] = `^${VERSION_MAJOR}.0.0`; | ||
} | ||
}); | ||
|
||
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
}); |
Oops, something went wrong.