Skip to content

Commit 990fa10

Browse files
authored
Update workflow for publishing packages (#3)
1 parent 5f20d9f commit 990fa10

File tree

6 files changed

+153
-36
lines changed

6 files changed

+153
-36
lines changed

.github/workflows/on-release.yml

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

.github/workflows/release.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Release on npm
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- packages/**/package.json
9+
10+
permissions:
11+
contents: write
12+
pull-requests: read
13+
id-token: write
14+
15+
jobs:
16+
build_and_publish:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Node
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version-file: ".nvmrc"
26+
registry-url: 'https://registry.npmjs.org'
27+
scope: '@makingchatbots'
28+
29+
- name: Install dependencies
30+
run: npm install
31+
32+
- name: Build
33+
run: |
34+
npm run clean
35+
npm run build
36+
37+
- id: publish_sdk
38+
name: Publish genesys-cloud-chatbot-tester
39+
uses: JS-DevTools/npm-publish@v3
40+
with:
41+
package: packages/genesys-cloud-chatbot-tester
42+
token: ${{ secrets.NPM_TOKEN }}
43+
dry-run: false
44+
provenance: true
45+
access: public
46+
47+
- id: publish_cli
48+
name: Publish genesys-cloud-chatbot-tester-cli
49+
uses: JS-DevTools/npm-publish@v3
50+
with:
51+
package: packages/genesys-cloud-chatbot-tester-cli
52+
token: ${{ secrets.NPM_TOKEN }}
53+
dry-run: false
54+
provenance: true
55+
access: public
56+
57+
- name: Post-publish genesys-cloud-chatbot-tester
58+
if: steps.publish_sdk.outputs.type != 'none'
59+
run: echo "Published genesys-cloud-chatbot-tester ${{ steps.publish_sdk.outputs.version }}"
60+
61+
- name: Post-publish genesys-cloud-chatbot-tester-cli
62+
if: steps.publish_cli.outputs.type != 'none'
63+
run: echo "Published genesys-cloud-chatbot-tester-cli ${{ steps.publish_cli.outputs.version }}"
64+
65+
- name: Configure changelog for genesys-cloud-chatbot-tester
66+
if: steps.publish_sdk.outputs.type != 'none'
67+
run: |
68+
cat <<'EOF' > changelog_config.json
69+
{"categories": [], "template": "## Commits:\n\n${{UNCATEGORIZED}}", "pr_template": "- ${{MERGE_SHA}} ${{TITLE}}"}
70+
EOF
71+
echo "last_tag=$(git describe --tags --match \"genesys-cloud-chatbot-tester-v*\" --abbrev=0 || echo)" >> $GITHUB_ENV
72+
73+
- name: Generate changelog for genesys-cloud-chatbot-tester
74+
if: steps.publish_sdk.outputs.type != 'none'
75+
id: changelog_tester
76+
uses: mikepenz/[email protected]
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
fromTag: "${{ env.last_tag }}"
81+
toTag: ${{ github.ref }}
82+
commitMode: true
83+
configuration: changelog_config.json
84+
85+
- name: Create release for genesys-cloud-chatbot-tester
86+
if: steps.publish_sdk.outputs.type != 'none'
87+
uses: actions/create-release@v1
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
with:
91+
tag_name: genesys-cloud-chatbot-tester-v${{ steps.publish_sdk.outputs.version }}
92+
release_name: genesys-cloud-chatbot-tester-v${{ steps.publish_sdk.outputs.version }}
93+
commitish: ${{ github.ref }}
94+
body: ${{ steps.changelog_tester.outputs.changelog }}
95+
draft: false
96+
prerelease: false
97+
98+
- name: Configure changelog for genesys-cloud-chatbot-tester-cli
99+
if: steps.publish_cli.outputs.type != 'none'
100+
run: |
101+
cat <<'EOF' > changelog_config.json
102+
{"categories": [], "template": "## Commits:\n\n${{UNCATEGORIZED}}", "pr_template": "- ${{MERGE_SHA}} ${{TITLE}}"}
103+
EOF
104+
echo "last_tag=$(git describe --tags --match \"genesys-cloud-chatbot-tester-cli-v*\" --abbrev=0 || echo)" >> $GITHUB_ENV
105+
106+
- name: Generate changelog for genesys-cloud-chatbot-tester-cli
107+
if: steps.publish_cli.outputs.type != 'none'
108+
id: changelog_cli
109+
uses: mikepenz/[email protected]
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
with:
113+
fromTag: "${{ env.last_tag }}"
114+
toTag: ${{ github.ref }}
115+
commitMode: true
116+
configuration: changelog_config.json
117+
118+
- name: Create release for genesys-cloud-chatbot-tester-cli
119+
if: steps.publish_cli.outputs.type != 'none'
120+
uses: actions/create-release@v1
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
with:
124+
tag_name: genesys-cloud-chatbot-tester-cli-v${{ steps.publish_cli.outputs.version }}
125+
release_name: genesys-cloud-chatbot-tester-cli-v${{ steps.publish_cli.outputs.version }}
126+
commitish: ${{ github.ref }}
127+
body: ${{ steps.changelog_cli.outputs.changelog }}
128+
draft: false
129+
prerelease: false
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
name: On Push
1+
name: test
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
413

514
jobs:
615
lint:
716
runs-on: ubuntu-latest
817
steps:
918
- uses: actions/checkout@v4
10-
- name: Setup Node
11-
uses: actions/setup-node@v4
19+
- uses: actions/setup-node@v4
1220
with:
13-
node-version: 18.x
21+
node-version-file: ".nvmrc"
1422
- run: npm install
1523
- run: npm run lint
1624
env:
@@ -20,10 +28,9 @@ jobs:
2028
runs-on: ubuntu-latest
2129
steps:
2230
- uses: actions/checkout@v4
23-
- name: Setup Node
24-
uses: actions/setup-node@v4
31+
- uses: actions/setup-node@v4
2532
with:
26-
node-version: 18.x
33+
node-version-file: ".nvmrc"
2734
- run: npm install
2835
- run: npm run build
2936
- run: npm run test
@@ -32,10 +39,9 @@ jobs:
3239
runs-on: ubuntu-latest
3340
steps:
3441
- uses: actions/checkout@v4
35-
- name: Setup Node
36-
uses: actions/setup-node@v4
42+
- uses: actions/setup-node@v4
3743
with:
38-
node-version: 18.x
44+
node-version-file: ".nvmrc"
3945
- run: npm install
4046
- run: npm run build
4147
- run: npm run build:docs
@@ -44,10 +50,9 @@ jobs:
4450
runs-on: ubuntu-latest
4551
steps:
4652
- uses: actions/checkout@v4
47-
- name: Setup Node
48-
uses: actions/setup-node@v4
53+
- uses: actions/setup-node@v4
4954
with:
50-
node-version: 18.x
55+
node-version-file: ".nvmrc"
5156
- run: npm install
5257
- run: npm run build
5358
- run: cd examples/api && npm run test:js

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
],
1313
"scripts": {
1414
"test": "npm test -w packages/genesys-cloud-chatbot-tester -w packages/genesys-cloud-chatbot-tester-cli",
15+
"clean": "npm run clean --workspaces --if-present",
1516
"lint": "npm run lint --workspaces --if-present",
1617
"lint:fix": "npm run lint:fix --workspaces --if-present",
1718
"build": "npm run build --workspaces --if-present",

packages/genesys-cloud-chatbot-tester-cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"author": "Lucas Woodward",
1919
"scripts": {
20-
"build": "rm -rf ./lib && tsc -p tsconfig.json",
20+
"clean": "rm -rf ./lib",
21+
"build": "npm run clean && tsc -p tsconfig.json",
2122
"test": "vitest run",
2223
"lint": "eslint . --ignore-pattern 'lib/*'",
2324
"lint:fix": "eslint . --ignore-pattern 'lib/*' --fix",

packages/genesys-cloud-chatbot-tester/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"author": "Lucas Woodward",
1919
"scripts": {
20-
"build": "rm -rf ./lib && tsc -p tsconfig.json",
20+
"clean": "rm -rf ./lib",
21+
"build": "npm run clean && tsc -p tsconfig.json",
2122
"build:readme": "cd ../.. && build-readme ./packages/genesys-cloud-chatbot-tester/README.md https://github.com/makingchatbots/genesys-cloud-chatbot-tester/tree/main",
2223
"test": "vitest run",
2324
"lint": "eslint . --ignore-pattern 'lib/*'",

0 commit comments

Comments
 (0)