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

Automise release process #4

Closed
wants to merge 10 commits into from
Closed

Automise release process #4

wants to merge 10 commits into from

Conversation

elkezza
Copy link
Contributor

@elkezza elkezza commented Jul 17, 2024

In order to have a consistent process for new SDK releases, this PR introduces two GitHub Actions workflows that automate the process of updating the OpenAPI definition, generating the SDK, and creating a new release.

Two files are added to the GitHub workflow:

  • .github/workflows/openapi.yaml:
    Same way in python-exoscale this file checks if there is any changes on the openapi and if yes it updated the local openapi file with new changes and commit the changes.

.github/workflows/generate-and-release.yaml
After new changes in main branch (now the works on "Automise release process") this action gets triggered and does the following:

  • increments the artifactVersion (SDK version)
  • removes the old SDK to avoid any conflicts or not needed files
  • generate the new SDK with the new version and updated openAPI
  • commit the changes
  • create a new release tag and commit

You can check the action to see the output of these two actions.

elkezza and others added 4 commits July 17, 2024 19:15
in order to have a consistent release process among all SDK, first step to create file that checks if there is any changes on the openapi and if yes then update the local openapi file
adding workflow the automate the release process:
- increments the artifactVersion (SDK version) 
- removes the old SDK to avoid any conflicts or not needed files
- generate the new SDK with new version and updated openAPI
- commit the changes
- create new release tag and commit
on:
push:
branches:
- Automise-release-process # to be changed into main after merge
Copy link
Member

Choose a reason for hiding this comment

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

I think you mean 'automate' instead of 'automise'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I meant automise, is another spelling of automize, just forgot "the".

- Automise-release-process # to be changed into main after merge
workflow_dispatch:
schedule:
- cron: '0 * * * *' # At :00 every hour
Copy link
Member

Choose a reason for hiding this comment

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

Why is this 'schedule' trigger needed? AFAIU your other action already triggers on this schedule, which should trigger this action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, the initial idea was to put both actions in the same file, I missed it after I separated them, I will remove it, thanks for the feedback : )

.github/workflows/openapi.yaml Show resolved Hide resolved
git add sdk/ # Add the generated SDK
git commit -m "Release ${new_version}"
git pull --rebase origin Automise-release-process
git push origin Automise-release-process
Copy link
Member

Choose a reason for hiding this comment

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

On line 6 you are triggering when you push to this branch Automise-release-process. That means this action will trigger itself in an infinite loop, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nicely spotted 👌
you are right, this should lead to infinite loop, strangely (lucky) this infinite loop was not triggered.

Copy link
Member

Choose a reason for hiding this comment

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

I think GitHub Actions may detect an infinite loop and prevent it, but we still shouldn't risk it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I agree.

push:
workflow_dispatch:
schedule:
- cron: '0 * * * *' # At :00 every hour

Choose a reason for hiding this comment

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

Building SDK every hour sounds way too aggressive, consider that during night and weekends there will never be any openapi spec changes. For me running once per day on workdays is optimal, but even if you limit hourly runs to workdays & work hours is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Predrag for the feedback : )
I took this from python-exoscale
Howevrt I agree with, the more longer the less risky, e.g. better to have one bugs-free update than 10 with bugs.

Choose a reason for hiding this comment

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

Understood, I'll create PR to change schedule for python-exoscale as well.

pom.xml Outdated Show resolved Hide resolved
elkezza and others added 6 commits July 18, 2024 13:54
updating the action to be triggered only when there is a change on the opanapi.yaml file this will avoid infinite loop risk.
.github/workflows/openapi.yaml Show resolved Hide resolved

steps:
- name: Checkout
uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

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

I think this always checks out the branch on which the action is performed. But if I understand the purpose of this action, it is to always be executed on the main branch right?
Since releases should always be tagged and built based on the main branch, how about checking out main here directly?
Then you don't need to do the git pull --rebase below, which can actually fail depending on your branch.

Did you test this action? Because I would be surprised if the git push step below actually works without assigning 'content: write' permissions to this Action.

@elkezza elkezza closed this Sep 12, 2024
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