Skip to content

Commit

Permalink
[SC-32565] Setup publishing on NPM (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrutman authored Jan 31, 2024
1 parent ffc9506 commit 4a58eb8
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
node-modules-dot-cache-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}-
- run: npm ci --prefer-offline --no-audit
- run: npm run prettier
- run: npx tsc --noEmit
- run: npm run test:ci
- run: npm run eslint
- run: npm run build
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Publish to npm"

on:
release:
types: [released]

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false # enqueue deployment jobs

env:
SLACK_DEPLOY_BOT_TOKEN: ${{ secrets.SLACK_DEPLOY_BOT_TOKEN }}
SLACK_DEPLOY_CHANNEL: ${{ vars.SLACK_DEPLOY_CHANNEL }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Post to Slack
uses: Fieldguide/action-slack-deploy-pipeline@v1
id: slack

- name: Checkout code
uses: actions/checkout@v4

- name: Parse version
id: version
run: echo "value=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT

- name: Update npm package version for build / publishing
run: npm version ${{ steps.version.outputs.value }} --no-git-tag-version

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
registry-url: "https://registry.npmjs.org"
scope: "@fieldguide"

- name: Install dependencies
run: npm ci --prefer-offline --no-audit

- name: Publish package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: "Post to Slack"
uses: Fieldguide/action-slack-deploy-pipeline@v1
if: always()
with:
thread_ts: ${{ steps.slack.outputs.ts }}
conclusion: true
Loading

0 comments on commit 4a58eb8

Please sign in to comment.