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

Github Workflow: Update update plugin version to also update nested version in package-lock.json #53503

Conversation

andrewserong
Copy link
Contributor

What?

Follow-up to #53499

Update the "update plugin version" workflow step so that it also updates the nested package version for Gutenberg.

Why?

In #53426, the Node and NPM versions were updated, which affects the structure of the package-lock.json file. As a result, there is now a .packages[''].version key that also needs to be bumped when version numbers are bumped.

How?

Update the jq logic so that it updates the .packages[""].version attribute in addition to the root .version attribute.

Testing Instructions

I'm not sure how to test this in an automatic way by running the step, however we can manually test the updated line by running it in a local environment.

  1. Make sure you have jq installed locally. On a Mac, you can install it by running brew install jq.
  2. Run the following line, which sets the VERSION variable before then running the code change proposed in this PR:

In this example we're updating to the string apples to make it clear, but in real world usage, the variable would be set to a real version number.

VERSION="apples" && cat <<< $(jq --tab --arg version "${VERSION}" '.version = $version | .packages[""].version = $version' package-lock.json) > package-lock.json

If you then run git diff, you should see that both the root .version attribute, and .packages[""].version have been updated:

image

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

Looks legit to me

Looks legit to me

diff --git a/package-lock.json b/package-lock.json
index 7fc6c3c6dc..93fb5e2cdc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
        "name": "gutenberg",
-       "version": "16.4.0",
+       "version": "apples",
        "lockfileVersion": 2,
        "requires": true,
        "packages": {
                "": {
                        "name": "gutenberg",
-                       "version": "16.4.0",
+                       "version": "apples",
                        "hasInstallScript": true,
                        "license": "GPL-2.0-or-later",

I guess we'll know pretty soon if it breaks, so it should be okay 🤷🏻

@andrewserong
Copy link
Contributor Author

I guess we'll know pretty soon if it breaks, so it should be okay 🤷🏻

Thanks for reviewing @ramonjd! This one isn't super urgent to get in since a release was just pushed. I'll leave this PR open overnight and if there's no objections, will merge it in tomorrow morning 🙂

@youknowriad
Copy link
Contributor

Makes sense. Thanks for the fix.

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Good catch!

@andrewserong
Copy link
Contributor Author

Thanks for the reviews, everyone! 🙇

@andrewserong andrewserong merged commit 7ab350e into trunk Aug 10, 2023
52 checks passed
@andrewserong andrewserong deleted the update/update-plugin-version-workflow-step-to-update-nested-package-version branch August 10, 2023 22:06
@github-actions github-actions bot added this to the Gutenberg 16.5 milestone Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants