Skip to content

Commit 0942319

Browse files
committed
Add publishing gh actions, update existing actions
1 parent df62abb commit 0942319

File tree

9 files changed

+183
-7
lines changed

9 files changed

+183
-7
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
### Summary
2+
3+
<!-- Summarize the change and indicate whether this will be a major/minor/patch change -->
4+
5+
### Checklist
6+
7+
- [ ] Added a changelog entry
8+
9+
### Authors
10+
11+
> List GitHub usernames for everyone who contributed to this pull request.
12+
13+
-
14+
15+
### Reviewers
16+
17+
@braintree/team-sdk-js

.github/workflows/ci-functional-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212
- name: Use Node.js
13-
uses: actions/setup-node@v1
13+
- uses: actions/setup-node@v4
1414
with:
15-
node-version: "18.x"
15+
node-version-file: .nvmrc
1616
- run: npm install
1717
- run: sudo apt-get install xvfb
1818
# there's a weird typescript incompatibility with jest types and mocha types

.github/workflows/ci-unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212
- name: Use Node.js
13-
uses: actions/setup-node@v1
13+
- uses: actions/setup-node@v4
1414
with:
15-
node-version: "18.x"
15+
node-version-file: .nvmrc
1616
- run: npm install
1717
- run: npm run lint
1818
- run: npm run test:unit

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This workflow will run tests using node, bump the npm version, deploy to npm, and create a release with notes
2+
3+
name: Publish to npm
4+
run-name: Deploy ${{ github.repository }} to npmjs by @${{ github.actor }}
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
version_type:
9+
description: "Version bump type (major, minor, patch)"
10+
required: true
11+
type: choice
12+
options:
13+
- major
14+
- minor
15+
- patch
16+
17+
env:
18+
NPM_REGISTRY: https://registry.npmjs.org/
19+
20+
concurrency: # prevent concurrent releases
21+
group: npm-publish
22+
cancel-in-progress: true
23+
24+
jobs:
25+
ci-unit-tests:
26+
uses: ./.github/workflows/ci-unit-tests.yml
27+
bump-version:
28+
needs: ci-unit-tests
29+
uses: ./.github/workflows/version-bump.yml
30+
with:
31+
version_type: ${{ inputs.version_type }}
32+
publish-npm:
33+
needs: bump-version
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version-file: .nvmrc
40+
registry-url: ${{ env.NPM_REGISTRY }}
41+
- run: npm ci
42+
- run: npm publish --provenance
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.BRAINTREE_NPM_ACCESS_TOKEN }}
45+
publish-release:
46+
needs: publish-npm
47+
uses: ./.github/workflows/release-notes.yml

.github/workflows/release-notes.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow will create a release for the most recent deploy
2+
3+
name: Create release
4+
run-name: Running github release
5+
on:
6+
workflow_dispatch:
7+
workflow_call:
8+
9+
jobs:
10+
create_release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Get version
17+
run: |
18+
git pull
19+
latest_version=$(awk '/^## / { if (p) exit; p=1 } p' CHANGELOG.md | grep '##' | sed 's/## //')
20+
if $(echo $latest_version | grep -q "(");then
21+
latest_version=$(echo $latest_version | sed 's/\ (.*$//')
22+
fi
23+
echo "latest_version=$(echo $latest_version)" >> $GITHUB_ENV
24+
25+
- name: Get details
26+
run: |
27+
{
28+
echo 'release_details<<EOF'
29+
awk '/^## / { if (p) exit; p=1 } p' CHANGELOG.md | sed '1d'
30+
echo EOF
31+
} >> $GITHUB_ENV
32+
33+
- name: Create Release
34+
id: create_release
35+
uses: actions/create-release@v1
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
38+
with:
39+
tag_name: ${{ env.latest_version }}
40+
release_name: v${{ env.latest_version }}
41+
body: "${{ env.release_details }}"
42+
draft: false
43+
prerelease: false

.github/workflows/version-bump.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This workflow will bump the version
2+
3+
name: Bump version and update changelog
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
version_type:
9+
description: "Version bump type (major, minor, patch)"
10+
required: true
11+
type: string
12+
workflow_dispatch:
13+
inputs:
14+
version_type:
15+
description: "Version bump type (major, minor, patch)"
16+
required: true
17+
type: choice
18+
options:
19+
- major
20+
- minor
21+
- patch
22+
23+
jobs:
24+
version_bump:
25+
runs-on: ubuntu-latest
26+
27+
permissions:
28+
contents: write
29+
30+
steps:
31+
- name: Checkout Repo
32+
uses: actions/checkout@v4
33+
34+
- name: Configure Github Credentials
35+
run: |
36+
git config user.name 'github-actions[bot]'
37+
git config user.email 'github-actions[bot]@users.noreply.github.com'
38+
39+
- name: Check Changelog
40+
run: |
41+
if ! grep -i -q "## UNRELEASED" CHANGELOG.md; then
42+
echo "Error: 'UNRELEASED' not found in CHANGELOG.md. Please ensure the changelog is correctly formatted."
43+
exit 1
44+
fi
45+
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version-file: .nvmrc
49+
50+
- name: Bump npm version
51+
run: |
52+
new_version=$(npm version ${{ inputs.version_type }})
53+
echo "new_version=$(echo $new_version | sed 's/v//')" >> $GITHUB_ENV
54+
55+
- name: Update changelog
56+
run: |
57+
today=$(date +'%Y-%m-%d')
58+
sed -i "s/## unreleased/## ${{ env.new_version }} (${today})/i" CHANGELOG.md
59+
60+
- name: Commit and push changes
61+
run: |
62+
git tag -m ${{ env.new_version }} ${{ env.new_version }}
63+
git add --all
64+
git commit -m "v${{ env.new_version }}"
65+
git push

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 6.0.3
4+
5+
- Fix a bug with not being able to remove handlers when targetFrames are used.
6+
37
## 6.0.2
48

59
- Update (sub-)dependencies

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"url": "git://github.com/braintree/framebus.git"
77
},
88
"homepage": "https://github.com/braintree/framebus",
9-
"version": "6.0.2",
9+
"version": "6.0.3",
1010
"main": "dist/index.js",
1111
"files": [
1212
"dist/"

0 commit comments

Comments
 (0)