-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Modify Publish Workflow * Update Readme.md * Update Workflow
- Loading branch information
Showing
3 changed files
with
89 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Create Release and Publish on Push to main | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Read version from package.json | ||
id: package_version | ||
run: echo "RELEASE_TAG=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | ||
|
||
- name: Create GitHub Release | ||
uses: "actions/github-script@v7" | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
script: | | ||
try { | ||
const response = await github.rest.repos.createRelease({ | ||
draft: false, | ||
generate_release_notes: true, | ||
name: process.env.RELEASE_TAG, | ||
owner: context.repo.owner, | ||
prerelease: false, | ||
repo: context.repo.repo, | ||
tag_name: process.env.RELEASE_TAG, | ||
}); | ||
core.exportVariable('RELEASE_ID', response.data.id); | ||
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org | ||
- run: npm ci | ||
- run: npm run build | ||
env: | ||
WATSON_URL: ${{ secrets.WATSON_URL }} | ||
APP_CLIP_BASE_URL: ${{ secrets.APP_CLIP_BASE_URL }} | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths-ignore: | ||
- "**.md" | ||
push: | ||
branches: | ||
- main | ||
- staging | ||
paths-ignore: | ||
- "**.md" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npm test |