Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
npm publish to @latest only when release type is released
Browse files Browse the repository at this point in the history
Summary:
The following case won't work --

npm publish is not triggered when a draft is saved and then published

This diff fix the case and introduce the following behavior:
1. when a new release is issued and not marked as pre-release, the npm package  with the latest tag will be updated.
2. if the new release is marked as pre-release, the npm packages with the next tag will be updated.
3. The above behavior doesn't change whether or not a draft is saved before the released.

p.s. updating the "prerelease" to "released" won't trigger the workflow, and its not desired. To make a release based on prerelease, please redo whatever steps are needed.

Reviewed By: raedle

Differential Revision: D33248441

fbshipit-source-id: f54e5fb0c2834429ed27f7c16655f6628f50944b
  • Loading branch information
liuyinglao authored and clarksandholtz committed Jan 19, 2022
1 parent b580458 commit f9a399d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: NPM Publish

on:
release:
types: [created]
types: [published]

jobs:
publish-npm-cli:
Expand All @@ -24,10 +24,16 @@ jobs:
run: yarn run build
- name: Unit Test
run: yarn run test
- name: Publish To NPM
- name: Publish To NPM latest
if: github.event.release.prerelease == false
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish To NPM next
if: github.event.release.prerelease == true
run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

publish-npm-core:
runs-on: ubuntu-latest
Expand All @@ -44,10 +50,16 @@ jobs:
run: npm version $GITHUB_REF_NAME
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Publish To NPM
- name: Publish To NPM latest
if: github.event.release.prerelease == false
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish To NPM next
if: github.event.release.prerelease == true
run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

publish-npm-template:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -75,7 +87,13 @@ jobs:
working-directory: ./react-native-template-pytorch-live/template
- name: Update package.json version to $GITHUB_REF_NAME
run: npm version $GITHUB_REF_NAME
- name: Publish To NPM
- name: Publish To NPM latest
if: github.event.release.prerelease == false
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish To NPM next
if: github.event.release.prerelease == true
run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

0 comments on commit f9a399d

Please sign in to comment.