From a4c610845c221b789235303097173a73011e9f5f Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 27 Aug 2024 10:06:49 -0700 Subject: [PATCH] ci: set up NPM publish --- .github/workflows/release.yaml | 6 +++++- packages/epo-react-lib/.clean-publish | 5 ++++- packages/epo-react-lib/package.json | 7 ++++++- packages/epo-react-lib/release.config.mjs | 13 ++++++++++++- packages/epo-widget-lib/.clean-publish | 5 ++++- packages/epo-widget-lib/package.json | 1 + packages/epo-widget-lib/release.config.mjs | 13 ++++++++++++- yarn.lock | 10 +++++----- 8 files changed, 49 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4eef7333..1d8a63e2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,7 +5,10 @@ on: - main permissions: - contents: read # for checkout + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance jobs: release: @@ -35,4 +38,5 @@ jobs: - name: Release env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: yarn release diff --git a/packages/epo-react-lib/.clean-publish b/packages/epo-react-lib/.clean-publish index 05640b49..39bd7d16 100644 --- a/packages/epo-react-lib/.clean-publish +++ b/packages/epo-react-lib/.clean-publish @@ -16,6 +16,9 @@ ".storybook", "src", "storybook-static", - "publish" + "publish", + "postcss.config.ts", + "release.config.mjs", + ".prettierignore" ] } diff --git a/packages/epo-react-lib/package.json b/packages/epo-react-lib/package.json index 1b5740f0..cc5b1b8b 100644 --- a/packages/epo-react-lib/package.json +++ b/packages/epo-react-lib/package.json @@ -9,6 +9,10 @@ "type": "git", "url": "https://github.com/lsst-epo/epo-react-lib" }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "tag": "latest" + }, "supportedLocales": [ "en", "es" @@ -27,7 +31,7 @@ "build-storybook:production": "yarn build-storybook -o ../../storybook-static", "test": "NODE_OPTIONS=--experimental-vm-modules jest --max-workers=2", "test:generate-output": "yarn test --json --outputFile=.jest-test-results.json || true", - "release": "semantic-release -e semantic-release-monorepo --debug" + "release": "yarn build && clean-publish --without-publish && semantic-release -e semantic-release-monorepo --debug" }, "files": [ "CHANGELOG.md", @@ -81,6 +85,7 @@ "@rubin-epo/epo-style-dictionary": "^0.1.0", "@rubin-epo/eslint-config-react": "^1.0.0-beta", "@semantic-release/github": "^10.1.7", + "@semantic-release/npm": "^12.0.1", "@semantic-release/release-notes-generator": "^14.0.1", "@storybook/addon-actions": "^7.6.3", "@storybook/addon-essentials": "^7.6.3", diff --git a/packages/epo-react-lib/release.config.mjs b/packages/epo-react-lib/release.config.mjs index c8286cd5..5032d00b 100644 --- a/packages/epo-react-lib/release.config.mjs +++ b/packages/epo-react-lib/release.config.mjs @@ -24,7 +24,18 @@ const release = { ], }, ], - ["@semantic-release/github"], + [ + "@semantic-release/github", + { + assets: [{ path: "tempPublish/**", label: "Package" }], + }, + ], + [ + "@semantic-release/npm", + { + pkgRoot: "tempPublish", + }, + ], ], }; diff --git a/packages/epo-widget-lib/.clean-publish b/packages/epo-widget-lib/.clean-publish index 05640b49..39bd7d16 100644 --- a/packages/epo-widget-lib/.clean-publish +++ b/packages/epo-widget-lib/.clean-publish @@ -16,6 +16,9 @@ ".storybook", "src", "storybook-static", - "publish" + "publish", + "postcss.config.ts", + "release.config.mjs", + ".prettierignore" ] } diff --git a/packages/epo-widget-lib/package.json b/packages/epo-widget-lib/package.json index 2e8839f4..d032397b 100644 --- a/packages/epo-widget-lib/package.json +++ b/packages/epo-widget-lib/package.json @@ -50,6 +50,7 @@ "@babel/core": "^7.20.12", "@rubin-epo/eslint-config-react": "^1.0.0-beta", "@semantic-release/github": "^10.1.7", + "@semantic-release/npm": "^12.0.1", "@semantic-release/release-notes-generator": "^14.0.1", "@storybook/addon-a11y": "^7.6.3", "@storybook/addon-actions": "^7.6.3", diff --git a/packages/epo-widget-lib/release.config.mjs b/packages/epo-widget-lib/release.config.mjs index c8286cd5..5032d00b 100644 --- a/packages/epo-widget-lib/release.config.mjs +++ b/packages/epo-widget-lib/release.config.mjs @@ -24,7 +24,18 @@ const release = { ], }, ], - ["@semantic-release/github"], + [ + "@semantic-release/github", + { + assets: [{ path: "tempPublish/**", label: "Package" }], + }, + ], + [ + "@semantic-release/npm", + { + pkgRoot: "tempPublish", + }, + ], ], }; diff --git a/yarn.lock b/yarn.lock index 71af3720..fb84e5c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4303,7 +4303,7 @@ p-filter "^4.0.0" url-join "^5.0.0" -"@semantic-release/npm@^12.0.0": +"@semantic-release/npm@^12.0.0", "@semantic-release/npm@^12.0.1": version "12.0.1" resolved "https://registry.yarnpkg.com/@semantic-release/npm/-/npm-12.0.1.tgz#ffb47906de95f8dade8fe0480df0a08dbe1b80c9" integrity sha512-/6nntGSUGK2aTOI0rHPwY3ZjgY9FkXmEHbW9Kr+62NVOsyqpKKeP0lrCH+tphv+EsNdJNmqqwijTEnVWUMQ2Nw== @@ -7385,10 +7385,10 @@ conventional-changelog-angular@^8.0.0: dependencies: compare-func "^2.0.0" -"conventional-changelog-conventionalcommits@>= 8.0.0", conventional-changelog-conventionalcommits@^7.0.2: - version "8.0.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-8.0.0.tgz#3fa2857c878701e7f0329db5a1257cb218f166fe" - integrity sha512-eOvlTO6OcySPyyyk8pKz2dP4jjElYunj9hn9/s0OB+gapTO8zwS9UQWrZ1pmF2hFs3vw1xhonOLGcGjy/zgsuA== +conventional-changelog-conventionalcommits@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-7.0.2.tgz#aa5da0f1b2543094889e8cf7616ebe1a8f5c70d5" + integrity sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w== dependencies: compare-func "^2.0.0"