Skip to content

Commit 3739f47

Browse files
Merge pull request #102 from mxenabled/wes/publishingWorkflow
add github workflow for unit tests, version checks, and publishing
2 parents 8959a83 + 01f5758 commit 3739f47

File tree

9 files changed

+131
-4
lines changed

9 files changed

+131
-4
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ash-wright123 @codingLogan @mwclemy @Jameson13B @wesrisenmay-mx
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Changelog updated
2+
3+
on: pull_request
4+
5+
jobs:
6+
check-changelog:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
13+
- name: Fetch master branch
14+
run: |
15+
git fetch origin master:master
16+
17+
- name: Install jq for JSON processing
18+
run: sudo apt-get install -y jq
19+
20+
- name: Check that changelog is updated
21+
run: |
22+
if ! git diff --name-only master | grep -q '^CHANGELOG.md$'; then
23+
echo "Error: CHANGELOG.md has not been updated."
24+
exit 1
25+
fi

.github/workflows/npmPublish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'Auto-publish NPM Package'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
push_to_registry:
10+
name: 'Setup, and publish'
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: 'Check out the repo'
15+
uses: actions/checkout@v4
16+
17+
- name: 'Set up Node'
18+
uses: actions/setup-node@v4
19+
with:
20+
registry-url: 'https://registry.npmjs.org'
21+
node-version: 'lts/*'
22+
check-latest: true
23+
24+
- name: 'Dependencies and tests'
25+
run: |
26+
npm ci
27+
npm run build
28+
29+
- name: 'Publish to NPM'
30+
uses: JS-DevTools/npm-publish@v3
31+
with:
32+
token: ${{ secrets.NPM_TOKEN }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 'NPM Version Check'
2+
3+
on: pull_request
4+
5+
jobs:
6+
push_to_registry:
7+
name: 'NPM Version Check'
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: 'Check out the repo'
12+
uses: actions/checkout@v4
13+
14+
- name: 'Set up Node'
15+
uses: actions/setup-node@v4
16+
with:
17+
registry-url: 'https://registry.npmjs.org'
18+
node-version: 'lts/*'
19+
check-latest: true
20+
21+
- name: 'Check if version is published'
22+
run: |
23+
PACKAGE_VERSION=$(npm pkg get version --workspaces=false | tr -d \")
24+
PACKAGE_NAME=$(npm pkg get name --workspaces=false | tr -d \")
25+
26+
# Run npm view and capture the exit code (success or failure)
27+
npm view "$PACKAGE_NAME@$PACKAGE_VERSION" --json > result.json 2>&1 || true
28+
29+
# Check the exit code to determine if the version exists
30+
if grep -q "is not in this registry." result.json; then
31+
echo "Version $PACKAGE_VERSION does not exist for $PACKAGE_NAME on npmjs.com. 🎉"
32+
exit 0
33+
else
34+
echo "Version $PACKAGE_VERSION already exists for $PACKAGE_NAME on npmjs.com. 😬🫠"
35+
echo "Please update the 'version' property in package.json and try again."
36+
exit 1
37+
fi

.github/workflows/unitTest.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Unit/Integration tests
2+
3+
on: pull_request
4+
5+
jobs:
6+
run-unit-tests:
7+
name: Unit tests
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Set up NodeJS
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 'lts/Iron'
18+
check-latest: true
19+
20+
- name: Install all dependencies
21+
run: |
22+
npm ci
23+
24+
- name: Run unit tests
25+
run: |
26+
npm run test

CHANGELOG.md

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

3+
## v.0.9.1
4+
5+
### Added
6+
7+
- Adding github workflows for a new publishing process
8+
39
## v.0.9.0
410

511
### Added

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
@@ -1,7 +1,7 @@
11
{
22
"name": "@mxenabled/connect-widget",
33
"description": "A simple ui library for React",
4-
"version": "0.9.0",
4+
"version": "0.9.1",
55
"module": "dist/index.es.js",
66
"types": "dist/index.d.ts",
77
"type": "module",

src/components/__tests__/GoBackButton-test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { render, screen, fireEvent } from 'src/utilities/testingLibrary'
33
import { GoBackButton } from '../GoBackButton'
44

5-
describe.only('GoBackButton', () => {
5+
describe('GoBackButton', () => {
66
const handleGoBack = vi.fn()
77

88
it('renders the go back button', () => {

0 commit comments

Comments
 (0)