1Password / onepassword-sdk-go

https://developer.1password.com/docs/sdks/
MIT License
53 stars 6 forks source link

Add tool-chain script to automate release #89

Closed MOmarMiraj closed 5 months ago

MOmarMiraj commented 5 months ago

This MR will create a two step release process that you can run on any branch and release the Go SDK.

This requires GitLab CLI installed and the MakeFile checks if you have it or not.

Also, a PAT will have to be created and exported to GITHUB_CLI_TOKEN environment variable to run the gitlab CLI. The minimum required scopes for the token are: repo, read:org, and gist.

The first script prep-release.sh will update the version/build numbers and create a new changelog for the release

The second script release.sh will create the release branch, add all necessary files, and create the release with the correct changelog and version

This process will ensure that the developer can verify the files before pushing a release.

A README is in the internal/changelogs folder on step by step process on how to push a release.

Build Number: image Build Number is updated on Logs: image

To Test

  1. Go into the test go sdk repo (https://github.com/MOmarMiraj/onepassword-sdk-go). I sent you three all invites to access the repo which should give you the correct permissions.
  2. Test on main/feature branch.. run make prep-release.. follow instructions
  3. Run make release

I have updated the fork repo to include the latest changes and edited it so the release will be created on the fork repo not the actual repo.. so just run the scripts and should be good to go.

hculea commented 5 months ago

Code looks good, but I would like a second look from @AndyTitu as well.

Additionally, can you please make the repository that you used for testing public, for us to also be able to functionally test?

Please update the description with the due testing steps.

hculea commented 5 months ago

Approving the code, but I would love if you could functionally test together with @AndyTitu such that he can confirm that the flow is the same as the one he follows when releasing.

AndyTitu commented 5 months ago

Functional test unexpected behaviour:

➜  onepassword-sdk-go git:(main) ✗ make release
scripts/release.sh
Saved working directory and index state WIP on main: 8d41aeb Fix state
Switched to a new branch 'rc/0.1.0-beta.12'
On branch rc/0.1.0-beta.12
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   internal/version
    modified:   internal/version-build

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    internal/changelogs/0.1.0-beta.12-0010012

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (bd06505bc4b8fc597a1f0044b68030fb8e0b3898)
[rc/0.1.0-beta.12 04b3796] Release v0.1.0-beta.12
 3 files changed, 4 insertions(+), 2 deletions(-)
 create mode 100644 internal/changelogs/0.1.0-beta.12-0010012
Everything up-to-date
https://github.com/MOmarMiraj/onepassword-sdk-go/releases/tag/v0.1.0-beta.12

Some lines from this log look weird such as:

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (bd06505bc4b8fc597a1f0044b68030fb8e0b3898)

The changes seem to have been committed from my inspections but my branch hasn't been pushed to the repo.

AndyTitu commented 5 months ago

Functionally tested both scripts thoroughly with all various input I could think of and the processes behave well apart from the 2 mentions. Also I left some code and dir structure suggestions

MOmarMiraj commented 5 months ago

Functional test unexpected behaviour:

➜  onepassword-sdk-go git:(main) ✗ make release
scripts/release.sh
Saved working directory and index state WIP on main: 8d41aeb Fix state
Switched to a new branch 'rc/0.1.0-beta.12'
On branch rc/0.1.0-beta.12
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  modified:   internal/version
  modified:   internal/version-build

Untracked files:
  (use "git add <file>..." to include in what will be committed)
  internal/changelogs/0.1.0-beta.12-0010012

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (bd06505bc4b8fc597a1f0044b68030fb8e0b3898)
[rc/0.1.0-beta.12 04b3796] Release v0.1.0-beta.12
 3 files changed, 4 insertions(+), 2 deletions(-)
 create mode 100644 internal/changelogs/0.1.0-beta.12-0010012
Everything up-to-date
https://github.com/MOmarMiraj/onepassword-sdk-go/releases/tag/v0.1.0-beta.12

Some lines from this log look weird such as:

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (bd06505bc4b8fc597a1f0044b68030fb8e0b3898)

The changes seem to have been committed from my inspections but my branch hasn't been pushed to the repo.

This is due to git stash pop as we didn't commit the changes that we popped, so this isn't really a error and is fine.

I just functionally tested the newest iteration and the branch is now being pushed.. don't know what the exact problem was but it works now and you can test in the test repo again.

AndyTitu commented 5 months ago

@MOmarMiraj My hunch is that the tests are failing due to the go:embed that now embeds the build version + new line, which makes for an invalid User Agent header