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

Add GH release workflow and bump-version action, fix hard-coded client version #66

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

austin-denoble
Copy link
Contributor

@austin-denoble austin-denoble commented Aug 14, 2024

Problem

We have a private function which returns a hard-coded version number which is used when we build the user-agent for requests originating from the client. This is difficult to maintain while releasing because Go releases are handled through GitHub and Git tags, and requires us to keep things in sync manually.

I also missed updating this for v1.0.0, so it needs to be bumped anyways.

We're also missing any kind of "official" release process for the Go client, which would be beneficial in standardizing versioning and the process for releasing the client now that we're >v1.0.0. I'd rather we have a GitHub workflow similar to the other clients even if it primarily involves bumping a hard-coded version file, and pushing a tag.

Solution

  • Replace the old hard-coded version with a new internal/version.go file which packages and holds internal.Version to be used within the client. This is the file that CI will manage and commit updates towards as we bump versions.
  • Add new GitHub action .github/actions/bump-version allowing us to easily bump the currentVersion using a specific releaseLevel (major, minor, patch), isPrerelease, and prereleaseSuffix if desired. This action was something @jhamon originally added to the pinecone-python-client. I've lifted it here with minor alterations to support just returning a new version_tag rather than modifying a file using fs which it does in the Python repo.
  • Add new GitHub workflow ./github/workflows/release.yaml to facilitate releasing the Go SDK by updating internal/version.go, and pushing the new tag. For prerelease, we just push the tag without committing.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test

I'll need to get the CI files into source before I can test the actual release process. My thinking here is I've updated the hard-coded value to the current v1.0.0, and I'd like to release a v1.0.1 to fix the current problem with the user-agent not matching. I think this is reasonable, but let me know if you don't agree.

The bump-version action itself was lifted directly from @jhamon's work including unit tests, so I think that is mostly safe. I'd spend the bulk of the review looking at my approach in release.yaml.


…icit file, add new github action for bump-version allowing us to easily bump a semver version with a prereleaseSuffix if desired, add new release github workflow to facillitate triggering releases for the Go sdk using git tags and updating the version.go file
@@ -0,0 +1 @@
node_modules/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This entire action was lifted from work @jhamon did previously: pinecone-io/pinecone-python-client#178

I'll call out lines I modified, which should be within action.js and index.js where I got rid of modifying local files via fs.readFileSync and fs.writeFileSync. I'm doing the file manipulating using sed in the release.yaml file.

Comment on lines +12 to +13
core.setOutput("version_tag", `v${newVersion}`);
}
Copy link
Contributor Author

@austin-denoble austin-denoble Aug 14, 2024

Choose a reason for hiding this comment

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

I got rid of the return newVersion here since we're not using it in index.js.

Comment on lines +3 to +8

action.bumpVersion(
core.getInput("currentVersion"),
core.getInput("bumpType"),
core.getInput("prereleaseSuffix")
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got rid of fs.readFileSynx, fs.writeFileSynx, and doing anything with the newVersion that used to get returned from the action.bumpVersion call. bumpVersion uses core.setOutput and then we use the output in the release.yaml workflow.

@@ -0,0 +1,3770 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bummer, but if we can move all of this junk into its own public repo and then reuse the action across our repos that would be lovely.

)

func getPackageVersion() string {
// update at release time
return "v0.5.0"
return internal.Version
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only fix to the code itself, and we're expecting the internal.Version value to be somewhat managed through the CI process.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@austin-denoble austin-denoble marked this pull request as ready for review August 14, 2024 21:22
Copy link
Contributor

@haruska haruska left a comment

Choose a reason for hiding this comment

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

👍

)

func getPackageVersion() string {
// update at release time
return "v0.5.0"
return internal.Version
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@@ -3,11 +3,12 @@ package useragent
import (
"fmt"
"strings"

"github.com/pinecone-io/go-pinecone/internal"
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't useragent already in this package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For Go, I don't think internal was explicitly a package until I added a file referencing package internal. useragent, control, data, and provider are all separate packages that are defined under /internal/ in the ,
repo but there's no inheritance or anything like that in Go, so you still need to explicitly pull in the internal package. At least that's my understanding.

const delimiter = `delimiter_${Math.floor(Math.random() * 100000)}`;
const convertedValue = toCommandValue(value);

// These should realistically never happen, but just in case someone finds a
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@austin-denoble austin-denoble merged commit b1754c6 into main Aug 16, 2024
3 checks passed
@austin-denoble austin-denoble deleted the adenoble/correct-versioning branch August 16, 2024 15:44
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.

4 participants