-
Notifications
You must be signed in to change notification settings - Fork 13
feat: publish to npm #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: publish to npm #159
Changes from all commits
62de9e9
656dfae
4f918a6
6098335
9ded46d
f771eaf
43df26d
aa24d41
7d88efd
af6f4f9
2924c63
43c2661
1f2d32d
e29aeae
c3b2371
f4b329c
a292ee1
363c171
79998e1
50b0641
745b999
44f497c
5010956
20b583c
918c340
9e7a648
8420044
edc1642
f0b2ce1
ae97511
321873e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Publish to NPM | ||
| description: Publish an npm package. | ||
| inputs: | ||
| prerelease: | ||
| description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.' | ||
| required: true | ||
| dry_run: | ||
| description: 'Is this a dry run. If so no package will be published.' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Publish | ||
| shell: bash | ||
| run: | | ||
| ./scripts/publish-npm.sh | ||
| env: | ||
| LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }} | ||
| LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ jobs: | |
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/checkout@v4 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bumping this for consistency. |
||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,34 @@ jobs: | |
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| homebrew-gh-secret: ${{secrets.HOMEBREW_DEPLOY_KEY}} | ||
| tag: ${{ inputs.tag }} | ||
|
|
||
| release-ldcli-npm: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the same as what's in the release-please action. |
||
| runs-on: ubuntu-latest | ||
| needs: ['release-ldcli'] | ||
| permissions: | ||
| actions: read | ||
| id-token: write | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| name: Checkout | ||
| with: | ||
| fetch-depth: 0 | ||
| - uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 20.x | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bumped to 20.x because of npm warning. |
||
| registry-url: 'https://registry.npmjs.org' | ||
| - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1 | ||
| name: 'Get NPM token' | ||
| with: | ||
| aws_assume_role: ${{ vars.AWS_ROLE_ARN }} | ||
| ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN' | ||
| - id: publish-npm | ||
| name: Publish NPM Package | ||
| uses: ./.github/actions/publish-npm | ||
| with: | ||
| prerelease: ${{ inputs.prerelease }} | ||
|
|
||
| release-ldcli-provenance: | ||
| needs: ['release-ldcli'] | ||
| permissions: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| .idea/ | ||
| dist/ | ||
| *.log | ||
| node_modules/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| cmd/ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to include these files in the npm package. |
||
| internal/ | ||
| main.go | ||
| vendor/ | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| .goreleaser.yaml | ||
| Dockerfile.goreleaser | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "name": "@launchdarkly/ldcli", | ||
| "description": "The official command line interface for managing LaunchDarkly feature flags.", | ||
| "version": "0.0.1", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gets overwritten similar to the go version variable. |
||
| "main": "index.js", | ||
| "scripts": { | ||
| "postinstall": "go-npm install", | ||
| "preuninstall": "go-npm uninstall" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/launchdarkly/ldcli.git" | ||
| }, | ||
| "keywords": [ | ||
| "cli", | ||
| "feature-flags", | ||
| "feature-toggles", | ||
| "command-line-interface", | ||
| "launchdarkly-integration" | ||
| ], | ||
| "author": "LaunchDarkly <team@launchdarkly.com>", | ||
| "license": "Apache-2.0", | ||
| "bugs": { | ||
| "url": "https://github.com/launchdarkly/ldcli/issues" | ||
| }, | ||
| "homepage": "https://github.com/launchdarkly/ldcli#readme", | ||
| "goBinary": { | ||
| "name": "ldcli", | ||
| "path": "./bin", | ||
| "url": "https://github.com/launchdarkly/ldcli/releases/download/v{{version}}/ldcli_{{version}}_{{platform}}_{{arch}}.tar.gz" | ||
| }, | ||
| "dependencies": { | ||
| "@go-task/go-npm": "^0.2.0" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,14 @@ | |
| "versioning": "always-bump-minor", | ||
| "bootstrap-sha": "f37bd3aee1f117faba005bf96f0d0888f898ee41", | ||
| "prerelease": true, | ||
| "extra-files": ["PROVENANCE.md"] | ||
| "extra-files": [ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This bumps the package-json version that npm needs. |
||
| "PROVENANCE.md", | ||
| { | ||
| "type": "json", | ||
| "path": "package.json", | ||
| "jsonpath": "$.version" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
| if $LD_RELEASE_IS_DRYRUN ; then | ||
| echo "Doing a dry run of publishing." | ||
| else | ||
| if $LD_RELEASE_IS_PRERELEASE ; then | ||
| echo "Publishing with prerelease tag." | ||
| npm publish --tag prerelease --provenance --access public || { echo "npm publish failed" >&2; exit 1; } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding the |
||
| else | ||
| npm publish --provenance --access public || { echo "npm publish failed" >&2; exit 1; } | ||
| fi | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changes when
LD_RELEASE_IS_PRERELEASEis set totrue?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be for tagging the npm package so we don't bump the normal version. We probably won't need to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you were going to be doing beta/alpha versions, then it would potentially be something you would want. (Or even nightlies 0.7.0-nightly-somesha).
Depending on how you are going to manage releases it may not be relevant.