-
Notifications
You must be signed in to change notification settings - Fork 2
Allow hotfix releases in the pipeline #100
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name-template: $RESOLVED_VERSION | ||
| tag-template: $RESOLVED_VERSION | ||
| categories: | ||
| - title: Features | ||
| labels: | ||
| - feature | ||
| - enhancement | ||
| - title: Bug Fixes | ||
| labels: | ||
| - fix | ||
| - bugfix | ||
| - bug | ||
| - title: Maintenance | ||
| labels: | ||
| - chore | ||
| - ci | ||
| - tech-debt | ||
| - title: Dependencies | ||
| label: dependencies | ||
| collapse-after: 3 | ||
| category-template: | | ||
| ### $TITLE | ||
| version-resolver: | ||
| major: | ||
| labels: | ||
| - major | ||
| - breaking | ||
| minor: | ||
| labels: | ||
| - feature | ||
| - minor | ||
| patch: | ||
| labels: | ||
| - patch | ||
| - bug | ||
| default: patch | ||
| exclude-labels: | ||
| - skip-release-notes | ||
| - released-as-hotfix | ||
| filter-by-commitish: true | ||
| template: | | ||
| ## What's Changed | ||
|
|
||
| $CHANGES | ||
|
|
||
| **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,12 @@ name: Do release | |
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| triggering_branch: | ||
| type: string | ||
| required: true | ||
| description: The branch on which we received a release request. | ||
|
|
||
| secrets: | ||
| release_key: | ||
| description: >- | ||
|
|
@@ -15,9 +21,13 @@ on: | |
| value: ${{ jobs.pre-release.outputs.version }} | ||
| description: "The determined version of the release" | ||
|
|
||
| env: | ||
| GIT_USER: shapbot | ||
| GIT_EMAIL: trento-developers@suse.com | ||
|
|
||
| jobs: | ||
| pre-release: | ||
| name: Detect new version, draft release, update changelog | ||
| name: Prepare a release | ||
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-24.04 | ||
|
|
@@ -28,6 +38,7 @@ jobs: | |
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 2 # required by detect-version step | ||
| ref: ${{ inputs.triggering_branch }} | ||
| ssh-key: ${{ secrets.release_key }} | ||
|
|
||
| - name: Detect new version | ||
|
|
@@ -45,10 +56,11 @@ jobs: | |
| id: draft-release | ||
| uses: release-drafter/release-drafter@v6 | ||
| with: | ||
| config-name: release_drafter_${{ inputs.triggering_branch }}.yaml | ||
| publish: false | ||
| commitish: ${{ inputs.triggering_branch }} | ||
| version: ${{ steps.detect-version.outputs.current-version }} | ||
| disable-autolabeler: true | ||
| config-name: release_drafter.yaml | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
|
|
@@ -61,27 +73,102 @@ jobs: | |
| - name: Commit new changelog | ||
| uses: stefanzweifel/git-auto-commit-action@v7 | ||
| with: | ||
| branch: main | ||
| # We need to checkout `branch` explicitly because | ||
| # `detect-version` messes with the HEAD ref. | ||
| branch: ${{ inputs.triggering_branch }} | ||
| skip_fetch: true | ||
| create_branch: false | ||
| commit_user_name: ${{ env.GIT_USER }} | ||
| commit_user_email: ${{ env.GIT_EMAIL }} | ||
| commit_author: "${{ env.GIT_USER }} <${{ env.GIT_EMAIL }}>" | ||
| commit_message: | | ||
| Automatically update CHANGELOG.md for release ${{ steps.detect-version.outputs.current-version }} | ||
|
|
||
| [skip ci] | ||
|
|
||
| cross-merge-branches: | ||
| name: Merge branches for full release | ||
| needs: [pre-release] | ||
| if: inputs.triggering_branch == 'main' | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Check out the repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: main | ||
| ssh-key: ${{ secrets.release_key }} | ||
|
|
||
| - name: Setup git | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment: totally out of scope, probably, but I wonder why we aren't signing the commits. See here how we are mixing up verified and non-verified commits: https://github.com/trento-project/ansible/commits/1.0.0 I guess this is simply because we don't have it elsewhere in the project... but perhaps it could be a good idea since we are revisiting some flows. |
||
| run: | | ||
| git config --global user.name "${GIT_USER}" | ||
| git config --global user.email "${GIT_EMAIL}" | ||
|
|
||
| - name: Switch to 'release' branch | ||
| run: git switch release 2>/dev/null || git switch -c release main | ||
|
|
||
| - name: Merge `main` into `release` | ||
| run: | | ||
| git merge main -X theirs --no-ff \ | ||
| -m "Release ${{ needs.pre-release.outputs.version }}" \ | ||
| -m "[skip ci]" | ||
|
|
||
| - name: Switch back to `main` branch | ||
| run: git switch main | ||
|
|
||
| - name: Merge `release` into main | ||
| run: git merge release --ff-only | ||
|
|
||
| - name: Push branches `main` and `release` | ||
| run: git push origin main release | ||
|
|
||
| hotfix-merge-branches: | ||
| name: Merge branches for hotfix release | ||
| needs: [pre-release] | ||
| if: inputs.triggering_branch == 'release' | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Check out the repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: main | ||
| ssh-key: ${{ secrets.release_key }} | ||
|
|
||
| - name: Setup git | ||
| run: | | ||
| git config --global user.name "${GIT_USER}" | ||
| git config --global user.email "${GIT_EMAIL}" | ||
|
|
||
| - name: Merge `release` into `main` | ||
| run: | | ||
| git merge origin/release -X ours --no-ff \ | ||
| -m "Merge Release ${{ needs.pre-release.outputs.version }} into main" \ | ||
| -m "[skip ci]" | ||
|
|
||
| - name: Push branch `main` | ||
| run: git push origin main | ||
|
|
||
| release: | ||
| name: Tag and publish release | ||
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-24.04 | ||
| needs: | ||
| - pre-release | ||
| needs: [pre-release, cross-merge-branches, hotfix-merge-branches] | ||
| # Hack: Implement poor man's "either or" logic for `needs`. | ||
| if: >- | ||
| always() | ||
| && contains(needs.*.result, 'success') | ||
| && !contains(needs.*.result, 'failure') | ||
| steps: | ||
| - name: Publish release | ||
| id: publish-release | ||
| uses: release-drafter/release-drafter@v6 | ||
| with: | ||
| config-name: release_drafter_${{ inputs.triggering_branch }}.yaml | ||
| publish: true | ||
| commitish: ${{ inputs.triggering_branch }} | ||
| version: ${{ needs.pre-release.outputs.version }} | ||
| disable-autolabeler: true | ||
| config-name: release_drafter.yaml | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment: Thank you for the explanation and summary. I'm not used to the release workflows in this project, so just dropping my two cents:
Relying on a manual two-step process seems really error-prone. At the very least, we would need a piece of documentation with step-by-step instructions on how to do it.
Don't know if it is an option, but, what about creating a kind of "backport PR workflow"?
For example, assuming we have an existing PR (against
main) for a hotfix, a maintainer could just comment with/backport. This way, the bot could:released-as-hotfixto both the backport PR and the original PR automatically.This way, we keep the release label-based dedupe logic, but we remove the manual work. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually sound amazing!
But I guess this would need developing a bot. I'm actually eager to work on that if others also thing it's worth it!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :P
Not really, I meant the existing
shapbot(like our hakube-bot) for the commits as the current PR does, but just using a workflow with a "comment" trigger that simply detects the/command.Alternatively, we could even avoid the GHA action for the changelog, and build manually using external tools, like Goreleaser changelog or github-changelog-generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah,
issue_commenttrigger would be piece of cake! Thanks, @antgamdia !I really don't like this gh action but our current release was relying on it and I wanted as little changes as possible. Anyway, it works with PRs, not commits, which gives us easy grouping based on PR labels. Of course, there could be other variants relying on naming or commit labeling, but we'll have to explore them in the future. This would also allow us to potentially de-couple from GH and make the process more universal.
/backportcommand seems to be a quick win, for now. Then we can expand on switching components further.