forked from segmentio/analytics-node
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
82 additions
and
38 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,82 @@ | ||
name: Deploy to NPM | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- master | ||
types: | ||
- closed | ||
|
||
permissions: | ||
id-token: write # allows the JWT to be requested from GitHub's OIDC provider | ||
contents: read # This is required for actions/checkout | ||
|
||
jobs: | ||
deploy-tag: | ||
name: Deploy to NPM | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/master') || github.event.pull_request.merged == true | ||
steps: | ||
- name: Checkout source branch | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
- name: Build files | ||
env: | ||
HUSKY: 0 | ||
run: | | ||
npm ci | ||
npm run build | ||
- name: Publish package to NPM | ||
env: | ||
HUSKY: 0 | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | ||
cd lib | ||
npm publish | ||
- name: Get new version number | ||
run: | | ||
current_version=$(jq -r .version package.json) | ||
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV | ||
echo "DATE=$(date)" >> $GITHUB_ENV | ||
- name: Send message to Slack channel | ||
id: slack | ||
uses: slackapi/slack-github-action@v1.23.0 | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | ||
PROJECT_NAME: 'Node SDK' | ||
NPM_PACKAGE_URL: 'https://www.npmjs.com/package/@rudderstack/rudder-sdk-node' | ||
with: | ||
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "header", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "New release: ${{ env.PROJECT_NAME }}" | ||
} | ||
}, | ||
{ | ||
"type": "divider" | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Release: <${{ env.NPM_PACKAGE_URL }}|${{ env.CURRENT_VERSION_VALUE }}>*\n${{ env.DATE }}" | ||
} | ||
} | ||
] | ||
} |