Skip to content

MM-32148 - Generate version metadata from tags#433

Merged
cpoile merged 14 commits intomasterfrom
MM-32148-generate-version-metadata
Jan 25, 2021
Merged

MM-32148 - Generate version metadata from tags#433
cpoile merged 14 commits intomasterfrom
MM-32148-generate-version-metadata

Conversation

@cpoile
Copy link
Copy Markdown
Member

@cpoile cpoile commented Jan 21, 2021

Summary

  • If the current commit has a tag, use that as the version (without the prefix 'v'). Otherwise, use the latest tag and add the short hash, eg. "1.2.0+9fcd0b92".
  • Q: should we also update the release_notes_url in plugin.json?

Ticket Link

@cpoile cpoile added the 2: Dev Review Requires review by a core committer label Jan 21, 2021
@cpoile
Copy link
Copy Markdown
Member Author

cpoile commented Jan 21, 2021

Doing some experimentation with e2e tests, will request reviews when that's all over with

@cpoile cpoile removed the 2: Dev Review Requires review by a core committer label Jan 21, 2021
@cpoile cpoile force-pushed the MM-32148-generate-version-metadata branch from 22e5420 to 8118ebd Compare January 21, 2021 23:33
@cpoile cpoile added the 2: Dev Review Requires review by a core committer label Jan 21, 2021
Copy link
Copy Markdown
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Nice! A few comments below.

plugin.json Outdated
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-incident-management/releases/tag/v1.2.0",
"icon_path": "assets/incident_plugin_icon.svg",
"version": "1.2.0",
"version": "1.2.0+9fcd0b92",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Propose we remove the version attribute from the checked-in file otherwise we'll always have a permanently old version checked in.

Copy link
Copy Markdown
Member Author

@cpoile cpoile Jan 22, 2021

Choose a reason for hiding this comment

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

I tried to do that, but couldn't think of a way to do it--bin/manifest will output the whole plugin.json, including the version field

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just manually edit the file in this PR to remove the version attribute? I guess then the manifest will always leave a modified plugin.json in the repo... which would be annoying. Can we write the output to a temporary plugin.json (i.e. the one that's being put into the bundle path)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, we can write the plugin.json anywhere, and change the bundle instructions. Will do that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There, the plugin.json is back in the root, but without the version field. The version field is generated and put into the build directory, and the make bundle copies that generated one to the dist folder. Looks good now, thanks!

"release_notes_url": "https://github.com/mattermost/mattermost-plugin-incident-management/releases/tag/v1.2.0",
"icon_path": "assets/incident_plugin_icon.svg",
"version": "1.2.0",
"version": "1.2.0+9fcd0b92",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we remove these files from the repo, and let them get generated only at build time? (Do we also .gitignore them?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was thinking of that, but then we would have to have the "base" plugin.json somewhere, so that we can read it in. I was thinking of putting it in the build directory. What do you think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I made that change so we can see what it looks like. It's not perfect though, because we still update the manifest files with the version info, and I can't think of a way to not have to check that in. Maybe ignore the manifest files as well since they're generated? Hmm, let's see if that will work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There, I think that works. Now the three generated files are not checked in. Only thing that feels a little "wrong" is putting the base plugin.json file in the build directory. Open to alternatives there. But if we keep it in the root directory it will be updated and we will start to check in old version numbers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oops, commented above before I read this thread. Yeah, wondering if we can keep the root one the base one, and change manifest to write to the temporary one in the bundle directory at build time?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As a compromise we're writing into the build directory, because we rm the dist directory before copying the manifest, and I don't want to mess around with that. :)

@cpoile cpoile requested a review from lieut-data January 22, 2021 18:53
@cpoile
Copy link
Copy Markdown
Member Author

cpoile commented Jan 22, 2021

@lieut-data @crspeller ready for re-review, then we can start testing the cloud build process. :)

Copy link
Copy Markdown
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Thanks, @cpoile! One comment below about build/plugin.json.

Makefile Outdated
CURL ?= $(shell command -v curl 2> /dev/null)
MM_DEBUG ?=
MANIFEST_FILE ?= plugin.json
MANIFEST_FILE ?= build/plugin.json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, this doesn't "smell right" to me -- at least from the context of reading the Makefile, MANIFEST_FILE is about defining the source of truth. This file doesn't exist yet: I'd love to see whatever temporary path we use be an implementation detail vs. something that's configured like this.

Maybe we just make pass the desired output path to bin/manifest and invoke it manually within the bundle target? Or, actually, "applying" plugin.json only needs to happen within the bundle target, so maybe it's just a different bin/manifest apply_version command or some such.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, that does work better, nice idea. I added a manifest dist command to write the plugin.json to the dist directory. Thanks!

@cpoile cpoile requested a review from lieut-data January 25, 2021 16:08
Copy link
Copy Markdown
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Copy Markdown
Member

@crspeller crspeller left a comment

Choose a reason for hiding this comment

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

Awesome!

"windows-amd64": "server/dist/plugin-windows-amd64.exe"
}
},
"executable": ""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did this come back?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like it was generated by marshalling the manifest struct. I can not check it in if it's causing confusion?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cpoile Nope its fine.

@cpoile cpoile added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Jan 25, 2021
@cpoile cpoile merged commit aea15de into master Jan 25, 2021
@cpoile cpoile deleted the MM-32148-generate-version-metadata branch January 25, 2021 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4: Reviews Complete All reviewers have approved the pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants