Skip to content

Commit

Permalink
feat: double publish the NPM packages into GitHub packages for use by…
Browse files Browse the repository at this point in the history
… internal repositories also using the @coveo scope (#3251)

https://coveord.atlassian.net/browse/KIT-2806

---------

Co-authored-by: Benjamin Taillon <54454747+btaillon-coveo@users.noreply.github.com>
  • Loading branch information
malaporte and btaillon-coveo authored Oct 26, 2023
1 parent af5f035 commit 4d413e6
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 21 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ on:
jobs:
release:
environment: 'Release'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
Expand All @@ -45,3 +43,12 @@ jobs:
RELEASER_CLIENT_SECRET: ${{ secrets.RELEASER_CLIENT_SECRET }}
RELEASER_INSTALLATION_ID: ${{ secrets.RELEASER_INSTALLATION_ID }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v3
with:
registry-url: 'https://npm.pkg.github.com'
node-version-file: '.nvmrc'
- name: Publish to GitHub Packages
run: npm run release:phase5
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions internal-docs/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ This task will create a new "version bump" commit, which will contain:

This task will also revert the changes from `release:phase0` to allow merging new features and fixes.

## `release:phase5` (publish to GitHub Packages)

This task will do the same thing as `release:phase2`, but is intended to publish the NPM package to GitHub Packages instead.

# Deploying

Whenever a new version bump is pushed to the main branch by the scheduled release process, the Jenkins CI will run the `Jenkinsfile` on it.
Expand Down
4 changes: 4 additions & 0 deletions internal-docs/scripts-and-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ Does the same thing as the `test` script, except:

- Does the same thing as the `test:watch` script, but runs end-to-end tests instead.

### `publish:npm` script

- Publishes the package to NPM.

### `publish:sfdx` script

- Publishes the package to the current Salesforce dev hub.
Expand Down
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
},
"release:phase2": {
"dependsOn": ["release:build", "release:phase1"]
},
"release:phase5": {
"dependsOn": ["^release:phase5"]
}
},
"defaultBase": "master",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
"release": "npm run nx:graph && npm run release:phase0 && npm run release:phase1-3 && npm run release:phase4",
"nx:graph": "nx graph --file=topology.json",
"release:phase0": "npx -p=@coveo/release git-lock",
"release:phase1-3": "nx run-many --targets=release:phase2 --all --parallel=false --output-style=stream && npx -p=@coveo/release reify",
"release:phase4": "npx -p=@coveo/release git-publish-all"
"release:phase1-3": "npm run release:phase2 && npx -p=@coveo/release reify",
"release:phase2": "nx run-many --targets=release:phase2 --all --parallel=false --output-style=stream",
"release:phase4": "npx -p=@coveo/release git-publish-all",
"release:phase5": "nx run-many --targets=release:phase5 --all"
},
"devDependencies": {
"@actions/core": "1.10.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/atomic-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"build": "nx build",
"build:bundles": "ng build",
"build:assets": "ncp ../atomic/dist/atomic/assets projects/atomic-angular/dist/assets && ncp ../atomic/dist/atomic/lang projects/atomic-angular/dist/lang",
"release:phase2": "node ./scripts/release-phase2.mjs"
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "node ./scripts/publish-npm.mjs"
},
"private": true,
"dependencies": {
Expand Down
8 changes: 0 additions & 8 deletions packages/atomic-angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
"command": "npx -p=@coveo/release bump",
"cwd": "packages/atomic-angular/projects/atomic-angular"
}
},
"release:phase2": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run release:phase2"],
"parallel": false,
"cwd": "packages/atomic-angular"
}
}
}
}
4 changes: 3 additions & 1 deletion packages/atomic-hosted-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"e2e": "cypress run --browser chrome",
"validate:definitions": "tsc --noEmit --esModuleInterop --skipLibCheck ./dist/types/components.d.ts",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"build:bundles:iife": "rollup --config rollup.config.mjs",
"build:bundles": "concurrently \"npm run build:bundles:esm\" \"npm run build:bundles:cjs\" \"npm run build:bundles:iife\"",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"build:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang "
},
Expand Down
4 changes: 3 additions & 1 deletion packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
"e2e:insight": "cypress run --config-file cypress-insight-panel.config.ts --browser chrome",
"e2e:insight:watch": "cypress open --config-file cypress-insight-panel.config.ts --browser chrome",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"validate:definitions": "tsc --noEmit --esModuleInterop --skipLibCheck ./dist/types/components.d.ts"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"build:definitions": "tsc -p src/tsconfig.build.json -d --emitDeclarationOnly --declarationDir dist/definitions",
"clean": "rimraf -rf dist/*",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"e2e": "npm run e2e:saml",
"e2e:saml": "vite manual-e2e/saml/"
Expand Down
4 changes: 3 additions & 1 deletion packages/bueno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"test": "jest",
"test:watch": "jest --watch --colors --no-cache",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/headless-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"test:watch": "jest --watch --colors --no-cache",
"lint": "eslint .; publint",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"test:unit": "jest --testPathIgnorePatterns=src/integration-tests",
"test:integration": "jest --testPathPattern=src/integration-tests",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"build:doc": "npm run build:doc:extract && npm run build:doc:parse",
"build:doc:extract": "node ./scripts/extract-documentation.mjs",
Expand Down
4 changes: 3 additions & 1 deletion packages/quantic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"promote:sfdx": "npm run publish:sfdx -- --promote",
"promote:sfdx:ci": "npm run publish:sfdx -- --promote --ci",
"release:phase1": "npx -p=@coveo/release bump",
"release:phase2": "npx -p=@coveo/release npm-publish",
"release:phase2": "npm run publish:npm",
"release:phase5": "npm run publish:npm",
"publish:npm": "npx -p=@coveo/release npm-publish",
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"preinstall": "node scripts/npm/check-sfdx-project.js",
"postinstall": "node scripts/npm/setup-quantic.js"
Expand Down
2 changes: 2 additions & 0 deletions utils/release/npm-publish-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ if (!(await isPublished(name, version))) {
},
{retries: 30}
);
} else {
console.log(`Version ${version} is already published.`);
}

0 comments on commit 4d413e6

Please sign in to comment.