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

v0.1 of GHA release automation #3094

Merged
merged 6 commits into from
Oct 27, 2020
Merged

Conversation

madchap
Copy link
Collaborator

@madchap madchap commented Oct 25, 2020

Base master is right.

This PR brings some automation to our release process. This is a v0.1 which I feel confident we can try for 1.9.0, but will appreciate eyes on it prior to that.

  1. [Triggered manually with maintainer input on version number] The first workflow will checkout dev, create a release branch, change version in files and commit them to finish by creating a PR. At that point, whoever is doing the release will review and take appropriate action. In the future, that PR may be dismissed for a full automated release.

Example of a manually merged PR, created by the GHA

image

The PR created by the 1st workflow needs to be merged before proceeding.

  1. [Triggered manually for now with maintainer input on version number, can change later to trigger on PR merge from step 1] This second workflow (which is 2 and 3 merged because of limitations on calling a workflow from another workflow) will create a tag, create a draft release (will have to copy-paste some release drafter note before manually publishing for now) and build&push docker images.

image

3. Added a third action to merge master back to dev.

Copy link
Collaborator

@ptrovatelli ptrovatelli left a comment

Choose a reason for hiding this comment

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

seems promising! could you check my remarks please? could you maybe let the result of the workflows sit somewhere for us to see what's the end result?

thanks!

.github/workflows/new-release-merge-back-to-master-pr.yml Outdated Show resolved Hide resolved
.github/workflows/new-release-merge-back-to-master-pr.yml Outdated Show resolved Hide resolved
.github/workflows/new-release-merge-back-to-master-pr.yml Outdated Show resolved Hide resolved
Comment on lines +36 to +55
- name: Update version numbers in key files
run: |
# sed -ri "s/'([0-9]+(\.[0-9]+)*)'/'${{ github.event.inputs.release_number }}'/" dojo/__init__.py
sed -ri "s/__version__ = '.*'/__version__ = '${{ github.event.inputs.release_number }}'/" dojo/__init__.py
sed -ri "s/version='.*'/version='${{ github.event.inputs.release_number }}'/" setup.py
sed -ri "s/appVersion: \"([0-9]+(\.[0-9]+)*)\"/appVersion: \"${{ github.event.inputs.release_number }}\"/" helm/defectdojo/Chart.yaml
- name: Check numbers
run: |
grep version dojo/__init__.py
grep version setup.py
grep appVersion helm/defectdojo/Chart.yaml
- name: Push version changes
uses: stefanzweifel/git-auto-commit-action@v4.1.2
with:
commit_user_name: "${{ env.GIT_USERNAME }}"
commit_user_email: "${{ env.GIT_EMAIL }}"
commit_author: "${{ env.GIT_USERNAME }} <${{ env.GIT_EMAIL }}>"
commit_message: "Update versions in application files"
branch: ${{ github.head_ref }}
- id: set-repo-org
Copy link
Collaborator

@ptrovatelli ptrovatelli Oct 27, 2020

Choose a reason for hiding this comment

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

if we change the version on dev branch before running this workflow, this duplicated version managment can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You mean like manually modifying before running the workflow?

Copy link
Collaborator

Choose a reason for hiding this comment

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

in the workflow. same as new-release-pr.yml but merges to dev instead of master, and rename the file to 01-version-change-on-dev-pr.yml.

if we remove the new-release-merge-back-to-master-pr.yml the version will be outdated in dev branch. it was serving at least this purpose although it's a pretty ugly way to have this version set in dev branch

Copy link
Collaborator

Choose a reason for hiding this comment

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

as discussed: the version in dev is diffferent than the version in the release so OK to leave it as it is for now

@ptrovatelli
Copy link
Collaborator

ptrovatelli commented Oct 27, 2020

or, how about this?

  • step 1: create a release branch, commit the version changes, merge the release branch to dev (same as new-release-pr.yml but merges to dev instead of master, and rename the file to 01-version-change-on-dev-pr.yml)
  • step 2: merge dev to master (new workflow to create 02-merge-dev-to-master-pr.yml)
  • step 3: merge master to dev: this is just in case, in most cases the PR should be cancelled. (same as new-release-merge-back-to-master-pr.yml but no version handling required and rename as 03-merge-master-to-dev-pr.yml)

@madchap
Copy link
Collaborator Author

madchap commented Oct 27, 2020

or, how about this?

  • step 1: create a release branch, commit the version changes, merge the release branch to dev (same as new-release-pr.yml but merges to dev instead of master, and rename the file to 01-version-change-on-dev-pr.yml)
  • step 2: merge dev to master (new workflow to create 02-merge-dev-to-master-pr.yml)
  • step 3: merge master to dev: this is just in case, in most cases the PR should be cancelled. (same as new-release-merge-back-to-master-pr.yml but no version handling required and rename as 03-merge-master-to-dev-pr.yml)

The goal was not to re-imagine our release process, rather automate the existing one.

Be my guest to rework these in another PR.

@ptrovatelli
Copy link
Collaborator

or, how about this?

  • step 1: create a release branch, commit the version changes, merge the release branch to dev (same as new-release-pr.yml but merges to dev instead of master, and rename the file to 01-version-change-on-dev-pr.yml)
  • step 2: merge dev to master (new workflow to create 02-merge-dev-to-master-pr.yml)
  • step 3: merge master to dev: this is just in case, in most cases the PR should be cancelled. (same as new-release-merge-back-to-master-pr.yml but no version handling required and rename as 03-merge-master-to-dev-pr.yml)

The goal was not to re-imagine our release process, rather automate the existing one.

Be my guest to rework these in another PR.

it's almost the same, just more straight forward and with less code duplication. we can discuss this and if everyone agree I can do the changes this week

@madchap madchap merged commit af9c71d into DefectDojo:master Oct 27, 2020
@valentijnscholten
Copy link
Member

nice job @madchap. At some point I'd like to see if we can get rid of that json (de)serialization parts that looks a bit out of place. Otherwise great to have some automation. Automate the release, so we have more time discuss topics on the agenda in the future.
Glad to have the release process ironed out so it doesn't need much more discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants