Skip to content
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

Update publish-to-npm workflow to accommodate alpha and beta packages #126

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

amolina-adobe
Copy link
Contributor

@amolina-adobe amolina-adobe commented Mar 6, 2024

Description

Problem

Currently, we don't have the ability to publish the CLI plugin to npm unless we merge our code changes to main. In the case of testing on the develop branch, as well as on epic branches, we don't want to have to merge incomplete changes to main for the sake of a publish. It's worth noting that most team members don't have permission to publish directly to the Adobe organization from their local machine, nor do we want to get into the practice of doing so.

Additionally, we don't have a dynamic way to add a tag to a publish even if we DID want to merge to main. The current process involves committing the tag in the workflow file and later reverting it. Failure to add the tag results the in publish being tagged as latest and automatically being installed on the next AIO update (which is bad).

Propsal

  • Any PR merge to the develop branch will attempt a publish as a beta package
    • consider that this is usually one step before release
    • we can change this to any release/* branch if we adopt that workflow
  • Any PR merge to an epic/* branch will attempt a publish as an alpha package
    • consider that there is likely still active development happening

Caveat

Opening up publishing from branches other than main can be error prone with regard to versioning (we don't want to publish the wrong branch as a latest version).

As such, this PR enforces the following:

  • the version in the package.json file MUST include the appropriate suffix in accordance to the tag it will be published with
  • the publish automatically assumes the proper tag (alpha, beta, latest) depending on the branch the PR was merged to

Example

A PR merge to the epic/cloudflare branch must be versioned as x.x.x-alpha[.x], and will automatically assume the alpha tag when published.

  • Failure to do so will result in the Publish to npm step of the workflow being skipped.
  • The current behavior of a pre-existing version in npm failing to re-publish will remain unchanged.

How Has This Been Tested?

Manually triggering the workflow.

Additional testing will be performed as the workflow is merged to various branches.

Screenshots (if appropriate):

image

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

@revanth0212 revanth0212 left a comment

Choose a reason for hiding this comment

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

Dude, this is nice work. This is what we were craving for. This helps soo much.

Have you tested this feature? Code wise it all looks good.

version_tag="latest"

elif [ "$target_branch" == "develop" ]; then
if [[ "${{ steps.get_version.outputs.version }}" =~ beta ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I am new to this, so can you confirm if this is checking for beta in the version string from get_version step?

Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think we should move forward with publishing if the version string does not have beta in case of merge to develop and alpha in case of epic/* branches.

During a publish the tag should match the version

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this checks if the version is beta if merged to develop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's the intention here. If it's the develop branch, it will only publish if the version has beta in it. Additionally, it will append the beta tag to the publish.

If you don't want to publish, then don't make it a beta version.

Copy link
Contributor

@brasewel brasewel left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@amolina-adobe
Copy link
Contributor Author

Dude, this is nice work. This is what we were craving for. This helps soo much.

Have you tested this feature? Code wise it all looks good.

I did my best to test this on a push to a feature/* branch (without performing an actual publish). There's a screenshot in the description that shows the flow. I'll know more as we merge it to each subsequent branch epic/cloudflare -> develop -> main

@amolina-adobe amolina-adobe merged commit 6a3a2c2 into epic/cloudflare Mar 8, 2024
3 checks passed
@amolina-adobe amolina-adobe deleted the feature/CEXT-2653-publish-action branch March 8, 2024 17:44
@amolina-adobe
Copy link
Contributor Author

Worked for the epic/cloudflare branch

image image

This command give you the latest: aio plugins:install @adobe/aio-cli-plugin-api-mesh
The command gives you the alpha: aio plugins:install @adobe/aio-cli-plugin-api-mesh@3.3.0-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants