Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/publish-to-npm.yml
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
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.lock file to this PR. Having it will ensure that the package published will be same as the version we tested locally.


- 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 }}
Copy link
Collaborator Author

@revanth0212 revanth0212 Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a process to get this Org Managed token. Ill try to find it tomorrow and update you on it. The process takes around a week, better to get started on it ASAP.

Sample:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will you start that process for us?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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 }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ oclif.manifest.json
/.nyc_output
/dist
/tmp
/yarn.lock
node_modules
.DS_Store
/test-results.xml
Expand Down
Loading