chore(release): pulling release/4.0.0 into main #9
Workflow file for this run
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
name: Deploy to NPM | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
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/main')) || ((startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true) # only merged pull requests must trigger this job | |
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 dist | |
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: 'Gatsby Plugin Rudderstack' | |
NPM_PACKAGE_URL: 'https://www.npmjs.com/package/rudder-sdk-js' | |
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 }}" | |
} | |
} | |
] | |
} |