Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/release_drafter_main.yaml
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

Choose a reason for hiding this comment

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

The take-aways are quite simple, after all:

  1. Nothing changes if we're going to release only full releases, as before.
  2. If you need to release a hotfix, you need to introduce the hotfix change with a PR marked with released-as-hotfix and also find the equivalent PR on main and retro-actively mark it with the same label.
  3. When making full release after hotfix, you don't need to do anything.

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:

  1. cherry-pick the merged PR onto release and open a backport PR.
  2. apply released-as-hotfix to both the backport PR and the original PR automatically.
  3. cross-link the PRs in body/comments.

This way, we keep the release label-based dedupe logic, but we remove the manual work. WDYT?

Copy link
Contributor Author

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!

Copy link

@antgamdia antgamdia Feb 16, 2026

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, issue_comment trigger 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.

/backport command seems to be a quick win, for now. Then we can expand on switching components further.

filter-by-commitish: true
template: |
## What's Changed

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
File renamed without changes.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ jobs:
needs: [ansible-lint, test-deploy]
uses: ./.github/workflows/publish-containers.yaml
with:
branch: main
image_name: ansible
tag: rolling
dockerfile: "docker/Dockerfile"
Expand Down
99 changes: 93 additions & 6 deletions .github/workflows/git-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}

Expand All @@ -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

Choose a reason for hiding this comment

The 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 }}
7 changes: 7 additions & 0 deletions .github/workflows/publish-containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Publish Containers
on:
workflow_call:
inputs:
branch:
type: string
required: true
description: The branch we want to build and publish.
registry:
required: false
type: string
Expand All @@ -29,6 +33,7 @@ on:
Additional build arguments that would be passed when
building the container. Value should be new-line delimited
string.

jobs:
detect-version:
name: Detect version
Expand All @@ -45,6 +50,7 @@ jobs:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ inputs.branch }}

- name: Get version from git
id: extract-version
Expand All @@ -65,6 +71,7 @@ jobs:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ inputs.branch }}

- uses: docker/setup-buildx-action@v3

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- release
paths:
- "VERSION"

Expand All @@ -13,6 +14,8 @@ jobs:
release:
name: Git Release
uses: ./.github/workflows/git-release.yaml
with:
triggering_branch: ${{ github.ref_name }}
secrets:
release_key: ${{ secrets.RELEASE_KEY }}

Expand All @@ -27,6 +30,7 @@ jobs:
- ${{ needs.release.outputs.version }}
- rolling
with:
branch: ${{ github.ref_name }}
image_name: ansible
tag: ${{ matrix.tag }}
dockerfile: "docker/Dockerfile"
Expand Down