Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/actions/publish-npm/action.yml
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 }}
Copy link
Copy Markdown

@sunnyguduru sunnyguduru Apr 15, 2024

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_PRERELEASE is set to true?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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.

LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
homebrew-gh-secret: ${{secrets.HOMEBREW_DEPLOY_KEY}}
tag: ${{ inputs.tag }}

release-ldcli-npm:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ jobs:
homebrew-gh-secret: ${{secrets.HOMEBREW_DEPLOY_KEY}}
tag: ${{ needs.release-please.outputs.tag_name }}

release-ldcli-npm:
runs-on: ubuntu-latest
needs: ['release-please', 'release-ldcli']
permissions:
id-token: write
contents: write
if: ${{ needs.release-please.outputs.release_created == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20.x
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 }}
dry_run: ${{ inputs.dry_run }}

release-ldcli-provenance:
needs: ['release-please', 'release-ldcli']
permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
dist/
*.log
node_modules/
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmd/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions package.json
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",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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"
}
}
9 changes: 8 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
"versioning": "always-bump-minor",
"bootstrap-sha": "f37bd3aee1f117faba005bf96f0d0888f898ee41",
"prerelease": true,
"extra-files": ["PROVENANCE.md"]
"extra-files": [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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"
}
]
}
}
}
11 changes: 11 additions & 0 deletions scripts/publish-npm.sh
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; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the --provenance flag!

else
npm publish --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
fi
fi