Skip to content

Commit

Permalink
Modify Publish Workflow (#3)
Browse files Browse the repository at this point in the history
* Modify Publish Workflow

* Update Readme.md

* Update Workflow
  • Loading branch information
TosinJs authored Mar 14, 2024
1 parent 2c0d734 commit 457e6cf
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 31 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/build_release.yml

This file was deleted.

65 changes: 65 additions & 0 deletions .github/workflows/publish.yml
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 }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
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

0 comments on commit 457e6cf

Please sign in to comment.