diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml deleted file mode 100644 index 36efb5f..0000000 --- a/.github/workflows/on-release.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Publish Package to npmjs -on: - release: - types: [published] -jobs: - test-build-publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - scope: '@makingchatbots' - - run: npm install - - run: npm run build - - run: npm run test - - run: npm run publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cf74484 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,129 @@ +name: Release on npm + +on: + push: + branches: + - "main" + paths: + - packages/**/package.json + +permissions: + contents: write + pull-requests: read + id-token: write + +jobs: + build_and_publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + registry-url: 'https://registry.npmjs.org' + scope: '@makingchatbots' + + - name: Install dependencies + run: npm install + + - name: Build + run: | + npm run clean + npm run build + + - id: publish_sdk + name: Publish genesys-cloud-chatbot-tester + uses: JS-DevTools/npm-publish@v3 + with: + package: packages/genesys-cloud-chatbot-tester + token: ${{ secrets.NPM_TOKEN }} + dry-run: false + provenance: true + access: public + + - id: publish_cli + name: Publish genesys-cloud-chatbot-tester-cli + uses: JS-DevTools/npm-publish@v3 + with: + package: packages/genesys-cloud-chatbot-tester-cli + token: ${{ secrets.NPM_TOKEN }} + dry-run: false + provenance: true + access: public + + - name: Post-publish genesys-cloud-chatbot-tester + if: steps.publish_sdk.outputs.type != 'none' + run: echo "Published genesys-cloud-chatbot-tester ${{ steps.publish_sdk.outputs.version }}" + + - name: Post-publish genesys-cloud-chatbot-tester-cli + if: steps.publish_cli.outputs.type != 'none' + run: echo "Published genesys-cloud-chatbot-tester-cli ${{ steps.publish_cli.outputs.version }}" + + - name: Configure changelog for genesys-cloud-chatbot-tester + if: steps.publish_sdk.outputs.type != 'none' + run: | + cat <<'EOF' > changelog_config.json + {"categories": [], "template": "## Commits:\n\n${{UNCATEGORIZED}}", "pr_template": "- ${{MERGE_SHA}} ${{TITLE}}"} + EOF + echo "last_tag=$(git describe --tags --match \"genesys-cloud-chatbot-tester-v*\" --abbrev=0 || echo)" >> $GITHUB_ENV + + - name: Generate changelog for genesys-cloud-chatbot-tester + if: steps.publish_sdk.outputs.type != 'none' + id: changelog_tester + uses: mikepenz/release-changelog-builder-action@v2.9.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + fromTag: "${{ env.last_tag }}" + toTag: ${{ github.ref }} + commitMode: true + configuration: changelog_config.json + + - name: Create release for genesys-cloud-chatbot-tester + if: steps.publish_sdk.outputs.type != 'none' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: genesys-cloud-chatbot-tester-v${{ steps.publish_sdk.outputs.version }} + release_name: genesys-cloud-chatbot-tester-v${{ steps.publish_sdk.outputs.version }} + commitish: ${{ github.ref }} + body: ${{ steps.changelog_tester.outputs.changelog }} + draft: false + prerelease: false + + - name: Configure changelog for genesys-cloud-chatbot-tester-cli + if: steps.publish_cli.outputs.type != 'none' + run: | + cat <<'EOF' > changelog_config.json + {"categories": [], "template": "## Commits:\n\n${{UNCATEGORIZED}}", "pr_template": "- ${{MERGE_SHA}} ${{TITLE}}"} + EOF + echo "last_tag=$(git describe --tags --match \"genesys-cloud-chatbot-tester-cli-v*\" --abbrev=0 || echo)" >> $GITHUB_ENV + + - name: Generate changelog for genesys-cloud-chatbot-tester-cli + if: steps.publish_cli.outputs.type != 'none' + id: changelog_cli + uses: mikepenz/release-changelog-builder-action@v2.9.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + fromTag: "${{ env.last_tag }}" + toTag: ${{ github.ref }} + commitMode: true + configuration: changelog_config.json + + - name: Create release for genesys-cloud-chatbot-tester-cli + if: steps.publish_cli.outputs.type != 'none' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: genesys-cloud-chatbot-tester-cli-v${{ steps.publish_cli.outputs.version }} + release_name: genesys-cloud-chatbot-tester-cli-v${{ steps.publish_cli.outputs.version }} + commitish: ${{ github.ref }} + body: ${{ steps.changelog_cli.outputs.changelog }} + draft: false + prerelease: false diff --git a/.github/workflows/on-push.yml b/.github/workflows/test.yml similarity index 74% rename from .github/workflows/on-push.yml rename to .github/workflows/test.yml index 25f697f..f80d0b6 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/test.yml @@ -1,16 +1,24 @@ -name: On Push +name: test -on: [push] +on: + push: + branches: + - "main" + pull_request: + branches: + - main + +permissions: + contents: read jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version-file: ".nvmrc" - run: npm install - run: npm run lint env: @@ -20,10 +28,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version-file: ".nvmrc" - run: npm install - run: npm run build - run: npm run test @@ -32,10 +39,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version-file: ".nvmrc" - run: npm install - run: npm run build - run: npm run build:docs @@ -44,10 +50,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version-file: ".nvmrc" - run: npm install - run: npm run build - run: cd examples/api && npm run test:js diff --git a/package.json b/package.json index db5e379..632e1a8 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ ], "scripts": { "test": "npm test -w packages/genesys-cloud-chatbot-tester -w packages/genesys-cloud-chatbot-tester-cli", + "clean": "npm run clean --workspaces --if-present", "lint": "npm run lint --workspaces --if-present", "lint:fix": "npm run lint:fix --workspaces --if-present", "build": "npm run build --workspaces --if-present", diff --git a/packages/genesys-cloud-chatbot-tester-cli/package.json b/packages/genesys-cloud-chatbot-tester-cli/package.json index 8a16b9b..9070adc 100644 --- a/packages/genesys-cloud-chatbot-tester-cli/package.json +++ b/packages/genesys-cloud-chatbot-tester-cli/package.json @@ -17,7 +17,8 @@ ], "author": "Lucas Woodward", "scripts": { - "build": "rm -rf ./lib && tsc -p tsconfig.json", + "clean": "rm -rf ./lib", + "build": "npm run clean && tsc -p tsconfig.json", "test": "vitest run", "lint": "eslint . --ignore-pattern 'lib/*'", "lint:fix": "eslint . --ignore-pattern 'lib/*' --fix", diff --git a/packages/genesys-cloud-chatbot-tester/package.json b/packages/genesys-cloud-chatbot-tester/package.json index 78050cd..7040230 100644 --- a/packages/genesys-cloud-chatbot-tester/package.json +++ b/packages/genesys-cloud-chatbot-tester/package.json @@ -17,7 +17,8 @@ ], "author": "Lucas Woodward", "scripts": { - "build": "rm -rf ./lib && tsc -p tsconfig.json", + "clean": "rm -rf ./lib", + "build": "npm run clean && tsc -p tsconfig.json", "build:readme": "cd ../.. && build-readme ./packages/genesys-cloud-chatbot-tester/README.md https://github.com/makingchatbots/genesys-cloud-chatbot-tester/tree/main", "test": "vitest run", "lint": "eslint . --ignore-pattern 'lib/*'",