Skip to content

Commit

Permalink
Publish version on NPM when release is published (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeelaudibert authored Dec 10, 2024
1 parent 0058b9e commit 9f28c51
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/push_to_npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Release"

on:
release:
types: [published]
workflow_dispatch:

jobs:
check-package-version:
name: Check package version and detect an update
runs-on: ubuntu-24.04
outputs:
committed-version: ${{ steps.check-package-version.outputs.committed-version }}
published-version: ${{ steps.check-package-version.outputs.published-version }}
is-new-version: ${{ steps.check-package-version.outputs.is-new-version }}
steps:
- name: Checkout the repository
uses: actions/checkout@v2

- name: Check package version and detect an update
id: check-package-version
uses: PostHog/check-package-version@v2

release:
name: Publish release if new version
runs-on: ubuntu-24.04
needs: check-package-version
if: needs.check-package-version.outputs.is-new-version == 'true'
env:
COMMITTED_VERSION: ${{ needs.check-package-version.outputs.committed-version }}
PUBLISHED_VERSION: ${{ needs.check-package-version.outputs.published-version }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}

- name: Setup Yarn
uses: threeal/setup-yarn-action@v2.0.0

- name: Set up Node 18
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org

- name: Install package.json dependencies with yarn
run: yarn install

- name: Publish the package in the npm registry
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 9f28c51

Please sign in to comment.