Skip to content

Commit

Permalink
add scripts and configure gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieseltzer committed Jan 24, 2025
1 parent 0e4381c commit d7e093f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: npmjs

on:
release:
types: [published]
workflow_dispatch:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'ngrok-oss/mantle'
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
Expand All @@ -24,17 +26,19 @@ jobs:

- run: pnpm install

- run: cd packages/mantle && pnpm publish --access public --no-git-checks
- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
with:
publish: pnpm release
version: pnpm version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Grab the released version and store it in an env variable
run: |
VERSION=$(jq -r '.version' ./packages/mantle/package.json)
echo "MANTLE_VERSION=$VERSION" >> $GITHUB_ENV
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Post to slack
if: steps.changesets.outputs.published == 'true'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PUBLISH_WEBHOOK_URL }}
MANTLE_VERSION: ${{ steps.changesets.outputs.publishedPackages[0].version }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":"`@ngrok/mantle@${{ env.MANTLE_VERSION }}` published to npm!\nInstall with: `pnpm add -E @ngrok/mantle@${{ env.MANTLE_VERSION }}`\n<https://github.com/ngrok-oss/mantle/releases/tag/v${{ env.MANTLE_VERSION }}|Release Notes>"}' $SLACK_WEBHOOK_URL
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"test:watch": "turbo run test:watch",
"test:ui": "turbo run test:ui",
"typecheck": "turbo run typecheck",
"changeset": "changeset"
"changeset": "changeset",
"version": "changeset version",
"release": "turbo run build --filter=@ngrok/mantle && changeset publish"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
Expand Down

0 comments on commit d7e093f

Please sign in to comment.