Version Packages (#409) #147
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: npmjs | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
actions: write | |
contents: write | |
pull-requests: write | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
if: github.repository == 'ngrok-oss/mantle' | |
env: | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: generate-token | |
with: | |
app-id: ${{ secrets.RELEASE_BOT_APP_ID }} | |
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.generate-token.outputs.token }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
registry-url: "https://registry.npmjs.org" | |
- name: Install pnpm 📦 | |
uses: pnpm/action-setup@v4 | |
# use version from package.json#packageManager field | |
- run: pnpm install | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
publish: pnpm -w changeset:publish | |
version: pnpm -w changeset:version | |
env: | |
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | |
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
- name: Extract MANTLE_VERSION | |
if: steps.changesets.outputs.published == 'true' | |
run: | | |
echo "Extracting MANTLE_VERSION..." | |
VERSION=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0].version') | |
echo "MANTLE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Post to slack | |
if: steps.changesets.outputs.published == 'true' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PUBLISH_WEBHOOK_URL }} | |
MANTLE_VERSION: ${{ env.MANTLE_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/%40ngrok%2Fmantle%40${{ env.MANTLE_VERSION }}|Release Notes>"}' $SLACK_WEBHOOK_URL |