Skip to content

Commit 69f98b6

Browse files
authored
build: Add release-please configuration. (#57)
1 parent 282a3fe commit 69f98b6

File tree

18 files changed

+399
-3
lines changed

18 files changed

+399
-3
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
workspace_path:
5+
description: 'The workspace to publish docs for'
6+
required: true
7+
default: 'packages/shared/common'
8+
type: choice
9+
options:
10+
- packages/shared/common
11+
- packages/shared/sdk-server
12+
- packages/sdk/server-node
13+
name: Publish Documentation
14+
jobs:
15+
build-publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: 16.x
22+
registry-url: 'https://registry.npmjs.org'
23+
- name: 'Set WORKSPACE_NAME variable'
24+
run: |
25+
WORKSPACE_NAME=$(./scripts/package-name.sh ${{ inputs.workspace_path }})
26+
echo "WORKSPACE_NAME=$WORKSPACE_NAME" >> $GITHUB_ENV
27+
- id: build
28+
# Build using the same steps from CI.
29+
name: Build and Test
30+
uses: ./actions/ci
31+
with:
32+
workspace_name: ${{ env.WORKSPACE_NAME }}
33+
workspace_path: ${{ inputs.workspace_path }}
34+
- id: publish
35+
name: Publish Documentation
36+
uses: ./actions/publish-docs
37+
with:
38+
workspace_path: ${{ inputs.workspace_path }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish Package
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
workspace_path:
6+
description: 'The workspace to publish'
7+
required: true
8+
default: 'packages/shared/common'
9+
type: choice
10+
options:
11+
- packages/shared/common
12+
- packages/shared/sdk-server
13+
- packages/sdk/server-node
14+
prerelease:
15+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
16+
type: boolean
17+
required: true
18+
dry_run:
19+
description: 'Is this a dry run. If so no package will be published.'
20+
type: boolean
21+
required: true
22+
23+
jobs:
24+
build-publish:
25+
runs-on: ubuntu-latest
26+
# Needed to get tokens during publishing.
27+
permissions:
28+
id-token: write
29+
contents: read
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: actions/setup-node@v3
33+
with:
34+
node-version: 16.x
35+
registry-url: 'https://registry.npmjs.org'
36+
- name: 'Set WORKSPACE_NAME variable'
37+
run: |
38+
WORKSPACE_NAME=$(./scripts/package-name.sh ${{ inputs.workspace_path }})
39+
echo "WORKSPACE_NAME=$WORKSPACE_NAME" >> $GITHUB_ENV
40+
- id: build-and-test
41+
# Build using the same steps from CI.
42+
name: Build and Test
43+
uses: ./actions/ci
44+
with:
45+
workspace_name: ${{ env.WORKSPACE_NAME }}
46+
workspace_path: ${{ inputs.workspace_path }}
47+
- id: publish
48+
name: Publish Package
49+
uses: ./actions/publish
50+
with:
51+
workspace_name: ${{ env.WORKSPACE_NAME }}
52+
prerelease: ${{ inputs.prerelease }}
53+
dry_run: ${{ inputs.dry_run }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: release-please
6+
7+
jobs:
8+
release-please:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
package-common-released: ${{ steps.release.outputs['packages/shared/common--release_created'] }}
12+
package-sdk-server-released: ${{ steps.release.outputs['packages/shared/sdk-server--release_created'] }}
13+
package-server-node-released: ${{ steps.release.outputs['packages/sdk/server-node--release_created'] }}
14+
steps:
15+
- uses: google-github-actions/release-please-action@v3
16+
id: release
17+
with:
18+
command: manifest
19+
token: ${{secrets.GITHUB_TOKEN}}
20+
default-branch: main
21+
22+
release-common:
23+
runs-on: ubuntu-latest
24+
needs: ['release-please']
25+
permissions:
26+
id-token: write
27+
contents: write
28+
if: ${{ needs.release-please.outputs.package-common-released }}
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-node@v3
32+
with:
33+
node-version: 16.x
34+
registry-url: 'https://registry.npmjs.org'
35+
- id: release-common
36+
name: Full release of packages/shared/common
37+
uses: ./actions/full-release
38+
with:
39+
workspace_path: packages/shared/common
40+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
41+
42+
release-sdk-server:
43+
runs-on: ubuntu-latest
44+
needs: ['release-please']
45+
permissions:
46+
id-token: write
47+
contents: write
48+
if: ${{ needs.release-please.outputs.package-sdk-server-released }}
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: actions/setup-node@v3
52+
with:
53+
node-version: 16.x
54+
registry-url: 'https://registry.npmjs.org'
55+
- id: release-common
56+
name: Full release of packages/shared/sdk-server
57+
uses: ./actions/full-release
58+
with:
59+
workspace_path: packages/shared/sdk-server
60+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
61+
62+
release-server-node:
63+
runs-on: ubuntu-latest
64+
needs: ['release-please']
65+
permissions:
66+
id-token: write
67+
contents: write
68+
if: ${{ needs.release-please.outputs.package-sdk-server-released }}
69+
steps:
70+
- uses: actions/checkout@v3
71+
- uses: actions/setup-node@v3
72+
with:
73+
node-version: 16.x
74+
registry-url: 'https://registry.npmjs.org'
75+
- id: release-common
76+
name: Full release of packages/sdk/server-node
77+
uses: ./actions/full-release
78+
with:
79+
workspace_path: packages/sdk/server-node
80+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}

.github/workflows/stale.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: 'Close stale issues and PRs'
2+
on:
3+
schedule:
4+
- cron: '30 1 * * *'
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v7
11+
with:
12+
stale-issue-message: 'This issue is stale because it has been open for 90 days without activity. Remove the stale label or comment, or this will be closed in 14 days.'
13+
days-before-stale: 90
14+
days-before-close: 14

.release-please-manifest.json

Whitespace-only changes.

actions/ci/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ inputs:
66
# Some commands work on the package name (yarn commands), other require the path (typedoc),
77
# so we supply both.
88
workspace_name:
9+
description: 'Name, from the package.json, of the package to build/test.'
910
required: true
10-
type: string
1111
workspace_path:
12+
description: 'Path to the package to release.'
1213
required: true
13-
type: string
1414

1515
runs:
1616
using: composite

actions/full-release/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build, Test, and Publish
2+
description: 'Execute the full release process for a workspace.'
3+
inputs:
4+
workspace_path:
5+
description: 'Path to the workspace being released.'
6+
required: true
7+
aws_assume_role:
8+
description: 'The ARN of an AWS IAM role to assume. Used to auth with AWS to upload results to S3.'
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: 'Set WORKSPACE_NAME variable'
15+
shell: bash
16+
run: |
17+
WORKSPACE_NAME=$(./scripts/package-name.sh ${{ inputs.workspace_path }})
18+
echo "WORKSPACE_NAME=$WORKSPACE_NAME" >> $GITHUB_ENV
19+
- uses: ./actions/ci
20+
with:
21+
workspace_name: ${{ env.WORKSPACE_NAME }}
22+
workspace_path: ${{ inputs.workspace_path }}
23+
- uses: ./actions/release-secrets
24+
name: 'Get NPM token'
25+
with:
26+
aws_assume_role: ${{ inputs.aws_assume_role }}
27+
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
28+
- name: Setup .yarnrc.yml
29+
shell: bash
30+
run: |
31+
yarn config set npmScopes.launchdarkly.npmRegistryServer "https://registry.npmjs.org"
32+
yarn config set npmScopes.launchdarkly.npmAlwaysAuth true
33+
yarn config set npmScopes.launchdarkly.npmAuthToken $NODE_AUTH_TOKEN
34+
- uses: ./actions/publish
35+
with:
36+
workspace_name: ${{ env.WORKSPACE_NAME }}
37+
prerelease: false
38+
dry_run: false
39+
- uses: ./actions/publish-docs
40+
with:
41+
workspace_path: ${{ inputs.workspace_path }}

actions/publish-docs/action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This action publishes docs. The docs must have been build prior.
2+
name: Publish Docs
3+
description: Publish documentation to github pages.
4+
inputs:
5+
workspace_path:
6+
description: 'The workspace to publish docs for'
7+
required: true
8+
runs:
9+
using: composite
10+
steps:
11+
# We put the github pages in another directory.
12+
- uses: actions/checkout@v3
13+
with:
14+
path: gh-pages
15+
ref: gh-pages
16+
- name: Publish Docs
17+
shell: bash
18+
run: |
19+
echo "Publishing docs for: $WORKSPACE"
20+
./scripts/publish-doc.sh
21+
env:
22+
WORKSPACE: ${{ inputs.workspace_path }}

actions/publish/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish to NPM
2+
description: Publish a package from the workspace.
3+
inputs:
4+
workspace_name:
5+
description: 'The workspace to publish'
6+
required: true
7+
prerelease:
8+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
9+
required: true
10+
dry_run:
11+
description: 'Is this a dry run. If so no package will be published.'
12+
required: true
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Publish
18+
shell: bash
19+
run: |
20+
echo "Publishing: $WORKSPACE"
21+
./scripts/publish.sh
22+
env:
23+
WORKSPACE: ${{ inputs.workspace_name }}
24+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
25+
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}

actions/release-secrets/action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release Secrets
2+
# Currently this handles SSM, but once we need an s3 secret we should add support.
3+
description: 'Action for getting release secrets from SSM'
4+
inputs:
5+
aws_assume_role:
6+
description: 'The ARN of an AWS IAM role to assume. Used to auth with AWS to upload results to S3.'
7+
required: true
8+
# This uses this format to allow using the GetParameters action.
9+
ssm_parameter_pairs:
10+
description: 'A series of pairs of paths to environment mappings. "/path = ENV_NAME", "/path2 = ENV_NAME2'
11+
required: false
12+
# If we add S3, then just have a list of S3 paths.
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Configure AWS Credentials
18+
uses: aws-actions/configure-aws-credentials@v1-node16
19+
with:
20+
audience: https://github.com/launchdarkly
21+
role-to-assume: ${{ inputs.aws_assume_role }}
22+
aws-region: us-east-1
23+
- uses: dkershner6/aws-ssm-getparameters-action@v1
24+
with:
25+
parameterPairs: ${{ inputs.ssm_parameter_pairs }}
26+
withDecryption: 'true'

0 commit comments

Comments
 (0)