Skip to content

Commit 132ac89

Browse files
authored
Merge pull request #123 from mxenabled/lr/workflow-update
GitHub Actions - Automate npm package updates and release notes
2 parents 631f579 + bd99992 commit 132ac89

File tree

8 files changed

+9631
-2775
lines changed

8 files changed

+9631
-2775
lines changed

.github/workflows/changelogCheck.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Check for Conventional Commits
2+
3+
on: pull_request
4+
5+
jobs:
6+
check_commits:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0 # Required to get all commits in the PR
13+
14+
- name: Check for conventional commits
15+
id: get_commits
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
run: |
19+
PR_NUMBER="${{ github.event.number }}"
20+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
21+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
22+
23+
BRANCH_COMMITS=$(git log --pretty="%s" $BASE_SHA...$HEAD_SHA)
24+
25+
echo $BRANCH_COMMITS
26+
27+
found_conventional_commit=false
28+
while IFS= read -r line; do
29+
# Checks for a <type>(<optional scope>)[optional !]: <description>
30+
pattern="^(feat|fix|build|chore|ci|docs|perf|refactor|revert|style|test)(\(.*\))*!*: .+"
31+
if [[ $line =~ $pattern ]]; then
32+
found_conventional_commit=true
33+
echo "Found conventional commit: $line"
34+
break
35+
fi
36+
done <<< "$BRANCH_COMMITS"
37+
38+
if [[ "$found_conventional_commit" == "false" ]]; then
39+
echo "::warning::The pull request does not contain at least one conventional commit. A new package version will not be created automatically for this pull request."
40+
exit 1
41+
else
42+
echo "::notice::The pull request contains at least one conventional commit."
43+
fi

.github/workflows/npmVersionCheck.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Semantic Release
2+
on:
3+
push:
4+
branches:
5+
- master # or main
6+
7+
permissions:
8+
contents: read # for checkout
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write # to be able to publish a GitHub release
16+
issues: write # to be able to comment on released issues
17+
pull-requests: write # to be able to comment on released pull requests
18+
id-token: write # to enable use of OIDC for npm provenance
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "lts/*"
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
# consider npm provenance, see https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/ci-configurations/github-actions.md#npm-provenance
34+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
35+
run: npm audit signatures
36+
37+
- name: Build
38+
run: npm run build
39+
40+
# Use npx semantic-release to determine the next version
41+
- name: Release
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
run: npx semantic-release

.github/workflows/tagAndPublish.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,33 @@ const App = () => {
5252

5353
You need to pass an object containing API endpoint callbacks as the `apiValue` prop of the ApiProvider as described in the [usage](#usage) section for the widget to work. [Here](./docs/APIDOCUMENTATION.md) is a more detailed list of the API endpoint callbacks.
5454

55-
## Developing
55+
## Development Set Up
5656

5757
1. Clone project
5858
2. Install `Node(with npm)`. See [package.json](/package.json) for current required versions
5959
3. Run `npm i`
60-
4. Make your code changes
60+
4. Make your code changes - [Follow Conventional Commits](#commit-message-requirements)
6161
5. Run `npm run build` to build the project
6262
6. [Link Project](#linking-for-development)
6363
7. Test your changes
64-
8. Update change log, translations, and documentation as needed
64+
8. Update translations and documentation as needed
6565
9. Open Pull Request
6666

67+
## Commit Message Requirements
68+
69+
_To make commits that trigger a package release, use `npx cz`, it will launch easy to follow commitizen prompts._
70+
71+
A new _MAJOR.MINOR.PATCH_ release will be generated if at least one of the following types are used, see [Conventional Commits Documentation](https://www.conventionalcommits.org/) for more specifics.
72+
* `fix:` -> PATCH bump
73+
* `feat:` -> MINOR bump
74+
75+
Major bump (any type with a footer of `BREAKING CHANGE:`)
76+
```
77+
<any_type>: <message>
78+
79+
BREAKING CHANGE: <description>
80+
```
81+
6782
## Linking for Development
6883

6984
For developing this package locally, we suggest you use npm link to connect your local version of the package to your client app using the package.

0 commit comments

Comments
 (0)