From 5521f8b4a19f76f2f37da1af346f5179ae9a1f6f Mon Sep 17 00:00:00 2001 From: Edie Lemoine Date: Wed, 13 Mar 2024 12:55:04 +0100 Subject: [PATCH] build: release @myparcel-do/shared --- .github/workflows/push.yml | 11 ++++++- .../vite-myparcel-lib.config.ts | 6 ++-- .../src/publish/index.ts | 3 -- .../publish/removeWorkspaceDependencies.ts | 31 ------------------- libs/shared/package.json | 1 - libs/shared/release.config.cjs | 26 ++++++++++++++++ 6 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 libs/semantic-release-plugin/src/publish/removeWorkspaceDependencies.ts create mode 100644 libs/shared/release.config.cjs diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 2a776ffe..c9a53195 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -61,7 +61,16 @@ jobs: --output-style="static" \ --target="build" - - name: 'Release' + - name: 'Release @myparcel-do/shared' + working-directory: libs/shared + # language=sh + run: | + npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GH_REPO_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: 'Release @myparcel/delivery-options' working-directory: apps/delivery-options # language=sh run: | diff --git a/apps/delivery-options/vite-myparcel-lib.config.ts b/apps/delivery-options/vite-myparcel-lib.config.ts index e56a31e9..14a42b88 100644 --- a/apps/delivery-options/vite-myparcel-lib.config.ts +++ b/apps/delivery-options/vite-myparcel-lib.config.ts @@ -1,4 +1,4 @@ -import {copyFileSync} from 'node:fs'; +import {writeFileSync} from 'node:fs'; import dts from 'vite-plugin-dts'; import {mergeConfig, type UserConfig} from 'vite'; import {createViteConfig} from '@myparcel-do/build-vite'; @@ -15,8 +15,8 @@ export default createViteConfig((env) => { entryRoot: 'src', rollupTypes: true, afterBuild: () => { - // To please publint, we need to copy the .d.ts file to .d.cts - copyFileSync('dist/index.d.ts', 'dist/index.d.cts'); + // To please publint, we need to also have a .d.cts file + writeFileSync('dist/index.d.cts', "export * from './index';"); }, }), ], diff --git a/libs/semantic-release-plugin/src/publish/index.ts b/libs/semantic-release-plugin/src/publish/index.ts index 0fae5083..f272a199 100644 --- a/libs/semantic-release-plugin/src/publish/index.ts +++ b/libs/semantic-release-plugin/src/publish/index.ts @@ -1,6 +1,5 @@ import {getPackageJson, hasErrors, throwIfHasErrors} from '../utils'; import {type PublishCmd} from '../types'; -import {removeWorkspaceDependencies} from './removeWorkspaceDependencies'; import {publishNpmPackage} from './publishNpmPackage'; import {gitPush} from './gitPush'; @@ -15,8 +14,6 @@ export const publish: PublishCmd = async (pluginConfig, context) => { return; } - await removeWorkspaceDependencies(context); - if (!hasErrors()) { await publishNpmPackage(context); } diff --git a/libs/semantic-release-plugin/src/publish/removeWorkspaceDependencies.ts b/libs/semantic-release-plugin/src/publish/removeWorkspaceDependencies.ts deleted file mode 100644 index 2dd33137..00000000 --- a/libs/semantic-release-plugin/src/publish/removeWorkspaceDependencies.ts +++ /dev/null @@ -1,31 +0,0 @@ -import {type NormalizedPackageJson} from 'read-pkg'; -import {getPackageJson, execute} from '../utils'; -import {type ContextWithNextRelease} from '../types'; - -export const removeWorkspaceDependencies = async (context: ContextWithNextRelease): Promise => { - const {env, cwd, logger} = context; - - const pkg = await getPackageJson(context); - - const filterWorkspaceVersion = ([, version]: [string, string]) => version.startsWith('workspace:'); - - const dependencies = Object.entries(pkg.dependencies ?? {}).filter(filterWorkspaceVersion); - const devDependencies = Object.entries(pkg.devDependencies ?? {}).filter(filterWorkspaceVersion); - - const itemsToDelete = [ - ...dependencies.map(([name]) => ['dependencies', name]), - ...devDependencies.map(([name]) => ['devDependencies', name]), - ]; - - const deletions = itemsToDelete.map(([type, name]) => `${type}.${name}`); - - if (deletions.length > 0) { - logger.log('Removing workspace dependencies from package.json'); - - await execute('npm', ['pkg', 'delete', ...deletions], {cwd, env}); - } else { - logger.log('No workspace dependencies to remove from package.json'); - } - - return pkg; -}; diff --git a/libs/shared/package.json b/libs/shared/package.json index 1e941317..edeb5ab1 100644 --- a/libs/shared/package.json +++ b/libs/shared/package.json @@ -1,7 +1,6 @@ { "name": "@myparcel-do/shared", "version": "6.0.0-beta.1", - "private": true, "description": "", "repository": { "type": "git", diff --git a/libs/shared/release.config.cjs b/libs/shared/release.config.cjs new file mode 100644 index 00000000..f108a184 --- /dev/null +++ b/libs/shared/release.config.cjs @@ -0,0 +1,26 @@ +/* eslint-disable no-template-curly-in-string */ +const { + addCommitAnalyzerPlugin, + addGitHubActionsOutputPlugin, + addReleaseNotesGeneratorPlugin, +} = require('@myparcel/semantic-release-config/src/plugins'); +const mainConfig = require('@myparcel/semantic-release-config'); + +/** + * @type {import('semantic-release').Options} + */ +module.exports = { + ...mainConfig, + extends: 'semantic-release-monorepo', + tagFormat: 'v${version}', + plugins: [ + addCommitAnalyzerPlugin(), + addGitHubActionsOutputPlugin(), + addReleaseNotesGeneratorPlugin(), + + /* + * Includes npm and git functionality + */ + '@myparcel-do/semantic-release-plugin', + ], +};