@celigo/npm-publish-test 0.0.0-stage → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +21 -2
  2. package/dist/index.js +16 -0
  3. package/package.json +24 -4
package/README.md CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # npm-publish-test
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Throwaway package for rehearsing the npmjs.org publish path before it is used on `celigo-cli` and `integrator-api-specs` (DEVOPS-17263). Nothing in this repository is meant to be used. Delete it when the proof of concept is done.
4
+
5
+ The package is `@celigo/npm-publish-test`. It has no dependencies and two functions, `greet` and `info`.
6
+
7
+ ## How it mirrors integrator-api-specs
8
+
9
+ - `make install` runs `npm ci`. `npm test` runs `make test`, which writes `Reports/UnitTestReport/index.html` and `code_coverage/index.html` even when a test fails, because the Jenkins `npm-publish` pipeline requires both.
10
+ - `prepack` builds `dist/`, and `files` publishes only `dist/`.
11
+ - `.github/workflows/publish-npm.yml` publishes from a GitHub-hosted runner with `id-token: write`. A GitHub release starts it. The release tag is the version, for example `0.0.2`, with no `v`. Tags that are not plain `x.y.z`, such as `0.0.2-some-branch`, are skipped.
12
+ - `repository.url` in `package.json` must stay `https://github.com/celigo/npm-publish-test.git`. npm checks it against the repository that runs the workflow.
13
+
14
+ ## Rehearsal
15
+
16
+ 1. Onboard this repository to `celigo/ci` and let the Jenkins `npm-publish` pipeline publish the first version with the existing token, the same way the live services publish. npm needs the package to exist before a trusted publisher can be added. The release Jenkins creates also starts `publish-npm.yml`, which fails because that version is already on npm. That red run is expected.
17
+ 2. On npmjs.com, open the package, then Settings, then Trusted publishing, and add a GitHub Actions publisher: organization `celigo`, repository `npm-publish-test`, workflow `publish-npm.yml`, environment blank, with direct `npm publish` allowed. A trusted publisher that has not published within 2 days of being saved expires.
18
+ 3. Run the workflow from the Actions tab with dry run on. It packs the tarball and uploads nothing, so it does not test the trust.
19
+ 4. Pass case. With the Jenkins change from `celigo/ci` pull request 2678 in place and `publicNpmWorkflow` set for this repository, merge a change. Jenkins creates the release, the workflow publishes it, and the Jenkins stage "Wait for npm publish" goes green.
20
+ 5. Fail case. Make the workflow fail on purpose, for example by re-running a version that is already on npm, and confirm the Jenkins build fails at "Wait for npm publish".
21
+ 6. Run the workflow with dry run off, `provenance` on, and `publish_version` set to the next patch. This shows whether `--provenance` is accepted from a non-public repository.
22
+ 7. Create a release with a tag such as `0.0.9-test-branch`. The workflow must finish green and publish nothing.
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ const pkg = require('../package.json')
4
+
5
+ function greet (name) {
6
+ if (typeof name !== 'string' || name.trim() === '') {
7
+ throw new TypeError('name must be a non-empty string')
8
+ }
9
+ return `Hello, ${name.trim()}!`
10
+ }
11
+
12
+ function info () {
13
+ return { name: pkg.name, version: pkg.version }
14
+ }
15
+
16
+ module.exports = { greet, info }
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@celigo/npm-publish-test",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.3",
4
+ "description": "Throwaway package used to rehearse the npmjs.org publish path (DEVOPS-17263). Safe to ignore.",
5
+ "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/celigo/npm-publish-test.git"
9
+ },
10
+ "main": "dist/index.js",
11
+ "files": [
12
+ "dist/"
13
+ ],
14
+ "engines": {
15
+ "node": ">=20"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "registry": "https://registry.npmjs.org/"
20
+ },
21
+ "scripts": {
22
+ "build": "node scripts/build.mjs",
23
+ "prepack": "npm run build",
24
+ "test": "make test"
25
+ }
26
+ }