Deploy to NPM #1
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: ['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 | |
env: | |
NODE_OPTIONS: "--no-warnings" | |
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 | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Yarn setup | |
uses: DerYeger/yarn-setup-action@master | |
with: | |
node-version: 10 | |
- name: Install dependencies | |
env: | |
HUSKY: 0 | |
run: | | |
yarn install --frozen-lockfile | |
- name: Get new version number & date | |
run: | | |
current_version=$(jq -r .version package.json) | |
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV | |
echo "DATE=$(date)" >> $GITHUB_ENV | |
- name: Publish package to NPM | |
env: | |
HUSKY: 0 | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_CONFIG_PROVENANCE: true | |
NPM_PACKAGE_NEW_VERSION: ${{ env.CURRENT_VERSION_VALUE }} | |
run: | | |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
yarn build | |
yarn release:ci | |
- name: Send message to Slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
PROJECT_NAME: 'Rudder Typer NPM Package' | |
NPM_PACKAGE_URL: 'https://www.npmjs.com/package/rudder-typer' | |
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 }}" | |
} | |
} | |
] | |
} |