Skip to content

Commit c9536c5

Browse files
authored
chore: Implement release please support. (#25)
1 parent 48f4cc1 commit c9536c5

11 files changed

+422
-279
lines changed

.github/actions/publish/action.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to NPM
2+
description: Publish js-eventsource to NPM.
3+
inputs:
4+
prerelease:
5+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
6+
required: true
7+
dry_run:
8+
description: 'Is this a dry run. If so no package will be published.'
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Publish
15+
shell: bash
16+
run: |
17+
if $LD_RELEASE_IS_DRYRUN ; then
18+
# Dry run just pack the workspace.
19+
echo "Doing a dry run of publishing."
20+
else
21+
if $LD_RELEASE_IS_PRERELEASE ; then
22+
echo "Publishing with prerelease tag."
23+
npm publish --tag prerelease --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
24+
else
25+
npm publish --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
26+
fi
27+
fi
28+
env:
29+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
30+
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}

.github/workflows/manual-publish.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Manual Publish Package
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
prerelease:
6+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
7+
type: boolean
8+
required: true
9+
dry_run:
10+
description: 'Is this a dry run. If so no package will be published.'
11+
type: boolean
12+
required: true
13+
14+
jobs:
15+
build-publish:
16+
runs-on: ubuntu-latest
17+
# Needed to get tokens during publishing.
18+
permissions:
19+
id-token: write
20+
contents: read
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20.x
27+
registry-url: 'https://registry.npmjs.org'
28+
29+
- uses: launchdarkly/gh-actions/actions/[email protected]
30+
name: 'Get the NPM token'
31+
with:
32+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
33+
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
34+
35+
- uses: ./.github/actions/publish
36+
name: Publish Package to npm
37+
with:
38+
prerelease: ${{ inputs.prerelease }}
39+
dry_run: ${{ inputs.dry_run }}

.github/workflows/release-please.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
release_created: ${{ steps.release.outputs.release_created }}
13+
steps:
14+
- uses: google-github-actions/release-please-action@v4
15+
id: release
16+
with:
17+
token: ${{secrets.GITHUB_TOKEN}}
18+
release-type: "go"
19+
20+
release-package:
21+
runs-on: ubuntu-latest
22+
needs: [ release-please ]
23+
permissions:
24+
id-token: write # Needed if using OIDC to get release secrets.
25+
contents: write # Contents and pull-requests are for release-please to make releases.
26+
pull-requests: write
27+
28+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 20.x
36+
registry-url: 'https://registry.npmjs.org'
37+
38+
- uses: launchdarkly/gh-actions/actions/[email protected]
39+
name: 'Get the NPM token'
40+
with:
41+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
42+
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
43+
44+
- uses: ./.github/actions/publish
45+
name: Publish Package to npm
46+
with:
47+
prerelease: false
48+
dry_run: false

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ yarn.lock
66
/coverage
77
package-lock.json
88
tmp
9+
.vscode

.ldrelease/build.sh

-15
This file was deleted.

.ldrelease/config.yml

-11
This file was deleted.

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.0.1"
3+
}

CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Repository Maintainers
2+
* @launchdarkly/team-sdk-js

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# EventSource [![npm version](http://img.shields.io/npm/v/launchdarkly-eventsource.svg?style=flat-square)](http://browsenpm.org/package/launchdarkly-eventsource)[![Circle CI](https://circleci.com/gh/launchdarkly/js-eventsource/tree/master.svg?style=svg)](https://circleci.com/gh/launchdarkly/js-eventsource/tree/master)[![NPM Downloads](https://img.shields.io/npm/dm/laumchdarkly-eventsource.svg?style=flat-square)](http://npm-stat.com/charts.html?package=launchdarkly-eventsource&from=2015-09-01)[![Dependencies](https://img.shields.io/david/launchdarkly/js-eventsource.svg?style=flat-square)](https://david-dm.org/launchdarkly/js-eventsource)
1+
# EventSource
2+
[![ci](https://github.com/launchdarkly/js-eventsource/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/js-eventsource/actions/workflows/ci.yml)
3+
[![npm version](http://img.shields.io/npm/v/launchdarkly-eventsource.svg?style=flat-square)](http://browsenpm.org/package/launchdarkly-eventsource)
4+
[![NPM Downloads](https://img.shields.io/npm/dm/laumchdarkly-eventsource.svg?style=flat-square)](http://npm-stat.com/charts.html?package=launchdarkly-eventsource&from=2015-09-01)
5+
26

37
This library is a pure JavaScript implementation of the [EventSource](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) client. The API aims to be W3C compatible.
48

0 commit comments

Comments
 (0)