-
Notifications
You must be signed in to change notification settings - Fork 1
Added github workflow to support NPM publish on merge #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: publish-to-npm | ||
| on: | ||
| pull_request: | ||
| types: [ closed ] | ||
| branches: | ||
| - main | ||
| - develop | ||
| # - epic/** | ||
| jobs: | ||
| publish: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout source | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup node | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: 18 | ||
|
|
||
| - name: Yarn install | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Get version from package.json | ||
| id: get_version | ||
| run: | | ||
| version=$(jq -r '.version' package.json) | ||
| echo "version=$version" >> $GITHUB_OUTPUT | ||
| echo "Read version $version from package.json" | ||
|
|
||
| - name: Verify version corresponds to branch | ||
| id: verify_version | ||
| run: | | ||
| target_branch="${GITHUB_REF#refs/heads/}" | ||
| version_tag="" | ||
|
|
||
| if [ "$target_branch" == "main" ]; then | ||
| version_tag="latest" | ||
|
|
||
| elif [ "$target_branch" == "develop" ]; then | ||
| if [[ "${{ steps.get_version.outputs.version }}" =~ beta ]]; then | ||
| version_tag="beta" | ||
| else | ||
| echo "Will not publish. Version on branch \"$target_branch\" is not beta."; | ||
| exit 0; | ||
| fi | ||
|
|
||
| # elif [[ $target_branch == epic/* ]]; then | ||
| # if [[ "${{ steps.get_version.outputs.version }}" =~ alpha ]]; then | ||
| # version_tag="alpha" | ||
| # else | ||
| # echo "Will not publish. Version on branch \"$target_branch\" is not alpha."; | ||
| # exit 0; | ||
| # fi | ||
|
|
||
| else | ||
| echo "Will not publish. Branch \"$target_branch\" is not designated for publish."; | ||
| exit 0; | ||
| fi | ||
|
|
||
| echo "version_tag=$version_tag" >> $GITHUB_OUTPUT; | ||
| echo "Will publish version ${{ steps.get_version.outputs.version }} as $version_tag" | ||
|
|
||
| - name: Publish to npm | ||
| if: ${{ steps.verify_version.outputs.version_tag != '' }} | ||
| uses: JS-DevTools/npm-publish@v1 | ||
| with: | ||
| token: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Will you start that process for us?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They usually expect the repo owners or code owners to do it. I can help you with the required steps but you will have to initiate the process.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK cool. No worries. Let me know how to kick that off and I will. |
||
| access: 'public' | ||
| tag: ${{ steps.verify_version.outputs.version_tag }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ oclif.manifest.json | |
| /.nyc_output | ||
| /dist | ||
| /tmp | ||
| /yarn.lock | ||
| node_modules | ||
| .DS_Store | ||
| /test-results.xml | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I didn't include a yarn.lock or package-lock.json. Do you have preference? Seems like mesh probably uses yarn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we use yarn. Its not necessary to do it that way. I left it so we could discuss. Hence I left the PR as a draft. Once we decide what to do, ill apply the changes and convert the PR to ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the
yarn.lockfile to this PR. Having it will ensure that the package published will be same as the version we tested locally.