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

ci(github): connect release reorganization #12444

Merged
merged 1 commit into from
May 24, 2024

Conversation

karliatto
Copy link
Member

@karliatto karliatto commented May 16, 2024

Description

This PR changes the process to release connect to be like below:

  1. Create a non-protected branch to update changelogs and bump versions
  2. Merging the previous branch to develop
  3. Triggering new workflow that will from specific commit from develop branch create the release/connect/... branch and will check what versions are different in package.json and NPM and it will trigger the workflows to release those with different versions
  4. The same workflow will trigger the relesase to staging (without permissions since it is just staging)
  5. Then we need to manually trigger the production release that will need to trigger by an authorized member and approved by other one.
  6. Release is done.

Release process

So the process would be:

  1. Run workflow .github/workflows/release-connect-bump-versions.yml
    • It will create a branch (non protected) with version bumped and changelogs most of it automated
    • This branch can be updated and modify until we get satisfying changelog
    • Once the changelogs and versions are fine we merge it to develop
  2. Run workflow .github/workflows/release-connect-init.yml using the commit hash of the previously merged bump-versions/connect-${version}.
    • It will create the branch release/connect/<version>
    • Automatically trigger github/workflows/release-connect-v9-staging.yml over the new created branch that will release to staging without any other approval.
    • Automatically trigger .github/workflows/release-connect-v9-production.yml over the new created release branch that will need approval from other member to release to production connect.trezor.io/9 for all the deployment types and only to connect.trezor.io/9.x.x for canary releases.
    • Automatically trigger .github/workflows/release-connect-npm-init.yml over new created release branch that will require approval to release all the npm dependencies.

Related Issue

Related #12157

@karliatto karliatto force-pushed the ci/refactor-order-of-connect-release branch 2 times, most recently from 32e940e to 5ddee00 Compare May 20, 2024 11:13
@karliatto karliatto changed the title wip wip: ci(github): connect release reorganization May 20, 2024
@karliatto karliatto force-pushed the ci/refactor-order-of-connect-release branch 4 times, most recently from d88e8f4 to 86cb240 Compare May 21, 2024 09:40
@karliatto karliatto changed the title wip: ci(github): connect release reorganization ci(github): connect release reorganization May 22, 2024
@karliatto karliatto marked this pull request as ready for review May 22, 2024 07:21
Copy link
Contributor

@mroz22 mroz22 left a comment

Choose a reason for hiding this comment

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

it looks nice. will get back to it later to read through it more carefully mostly to make sure that I understand everything.

.github/workflows/release-connect-bump-versions.yml Outdated Show resolved Hide resolved
.github/workflows/release-connect-init.yml Show resolved Hide resolved
.github/workflows/release-connect-npm-init.yml Outdated Show resolved Hide resolved

jobs:
bump-versions:
if: github.repository == 'trezor/trezor-suite'
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that not all the jobs here have this check. should they have it? or is it enough only for the first job to have it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I actually think that if: github.repository == 'trezor/trezor-suite' should be only used in workflows that are run automatically like the tests ones, to avoid running when running in forks. But this one has to be triggered manually so I would say it is not necessarily. @vdovhanych could you confirm it?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can get rid of it for release workflows

@karliatto karliatto force-pushed the ci/refactor-order-of-connect-release branch from 86cb240 to cf2d60f Compare May 23, 2024 06:56
Comment on lines -44 to -46
git config --global user.name "trezor-ci"
git config --global user.email "${{ secrets.TREZOR_BOT_EMAIL }}"
gh config set prompt disabled
Copy link
Member Author

Choose a reason for hiding this comment

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

@vdovhanych getting rid of "trezor-ci" git user here, since I think this was totally unnecessary.

Copy link
Member

Choose a reason for hiding this comment

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

Ok

run: |
echo ${{ env.BRANCH_NAME }}
git checkout -b ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }}
Copy link
Member Author

Choose a reason for hiding this comment

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

@vdovhanych as agreed I am not adding here the "trezor-ci" bot credential and name since this branch is going to be created by the user that triggers the action.

Copy link
Member

Choose a reason for hiding this comment

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

How is this supposed to work? Its trying to push te code to protected branch. It wont work like this, we don't want to have automation rights to push commits to protected branch.

Copy link
Contributor

@mroz22 mroz22 left a comment

Choose a reason for hiding this comment

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

the new system sounds good to me. I just pointed few nitpicks around the review, not really important ones.

Maybe please wait also for @vdovhanych and his second approval 🙏

@@ -0,0 +1,37 @@
name: "[Release] connect bump versions"
Copy link
Member

Choose a reason for hiding this comment

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

This will run and create a new unprotected branch with updated versions and create a pull request to the protected branch?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will create a new unprotected branch with update versions and create a pull request to develop.
Then we merge it to develop and once it is in develop we run the other workflow .github/workflows/release-connect-init.yml to create the protected branch release/connect/...

Copy link
Member

Choose a reason for hiding this comment

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

ok

run: |
echo ${{ env.BRANCH_NAME }}
git checkout -b ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }}
Copy link
Member

Choose a reason for hiding this comment

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

How is this supposed to work? Its trying to push te code to protected branch. It wont work like this, we don't want to have automation rights to push commits to protected branch.

@@ -0,0 +1,37 @@
name: Check connect version match with branch
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be called [Template] ...

Copy link
Member

Choose a reason for hiding this comment

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

Also i would probably convert this to action as this is something that is quite static and wont be changing that often (but its super low priority)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I made new action .github/actions/check-connect-version-match/action.yml

Comment on lines -44 to -46
git config --global user.name "trezor-ci"
git config --global user.email "${{ secrets.TREZOR_BOT_EMAIL }}"
gh config set prompt disabled
Copy link
Member

Choose a reason for hiding this comment

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

Ok


- name: Create and push new branch
env:
BRANCH_NAME: "release/connect/${{ needs.extract-version.outputs.version }}"
Copy link
Member

Choose a reason for hiding this comment

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

This is where what branch its pushing to is specified. W probably want to push the code to create-push-release-branch: branch that was created in that job at the line 46.

Copy link
Member

Choose a reason for hiding this comment

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

What about this still?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will now be done by the "trezor-ci".

git push origin ${{ env.BRANCH_NAME }}
echo "branch_name=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT

trigger-v9-staging-release:
Copy link
Member

Choose a reason for hiding this comment

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

Im not sure if this will do what we want, if we trigger the workflows like this it will still be possible to approve the run by one person. I trigger release and i can approve it myself because the deploy was requested by the github-actions "user". This is valied for all following trigger jobs

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, I think you are right.
I am researching if there is a way of using the same user that triggered the action as the one that trigger it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I have an idea, what if instead of running those workflows using gh I will make those workflows templates that will run in the original workflow release-connect-init.yml ?

Then it will all be run by the user that is triggering the initial workflow, right?

Copy link
Member Author

@karliatto karliatto May 23, 2024

Choose a reason for hiding this comment

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

Now it seams even more right in my mind.

Copy link
Member Author

@karliatto karliatto May 23, 2024

Choose a reason for hiding this comment

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

Maybe it is problematic with "approval" since the approval are per workflow not per job. Right?
And in my mind this is design to approve each workflow at a different moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or we can do the process a bit more manual and trigger those workflows manually at least for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, for now I suggest get rid of the automation of triggering all the workflows from one and trigger them manually until we decide how to do it in order to achieve that each of the releases part has to be trigger by one authorize user and approve by other.

Therefore I added this fixup to remove all those trigger... jobs 3029015

@vdovhanych if you agree I will squash that fixup and we can try manually then we will see.

env:
BRANCH_NAME: release/connect/${{ needs.extract-version.outputs.version }}

trigger-npm-release-connect:
Copy link
Member

Choose a reason for hiding this comment

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

same here with te triggering the action with github actions.

Copy link
Member

Choose a reason for hiding this comment

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

I dont think this is resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, just getting rid of that file completely since this time we are going to run those workflows manually 95ffe13

gh config set prompt disabled
gh api /user --jq .login
node ./ci/scripts/connect-release-init-npm.js ${{ github.event.inputs.semver }}
yarn tsx ./ci/scripts/connect-release-npm-init.ts ${{ github.event.inputs.deploymentType }} ${{ env.BRANCH_NAME }}
Copy link
Member

Choose a reason for hiding this comment

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

This again tries to push the code to the protected branch. Or I'm missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this is not pushing code to any protected branch. This is triggering the workflow that will initialize the release of NPM.

It requires to have a script that checks what are the dependencies that need to be updated.

Please look at the section ## Release process in the description of this PR, I am trying to explain there the process. And let' me know if you have doubts or ideas.

Copy link
Member

Choose a reason for hiding this comment

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

Ok

@karliatto karliatto force-pushed the ci/refactor-order-of-connect-release branch 3 times, most recently from 95ffe13 to 36bd85e Compare May 24, 2024 09:17
@karliatto karliatto force-pushed the ci/refactor-order-of-connect-release branch from 36bd85e to db94318 Compare May 24, 2024 09:18
@karliatto karliatto merged commit 6c09263 into develop May 24, 2024
25 checks passed
@karliatto karliatto deleted the ci/refactor-order-of-connect-release branch May 24, 2024 12:23
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