Skip to content

Commit 1fa7454

Browse files
authored
Allow to create release from existing branch; allow to preserve existing .deps and .build files; improve docs (#404)
* Allow to preserve existing .deps files. * Allow to create a PR from an existing branch. * By default, allow to reset the .build file. * Document some special builds that need the new options. * Prefix branch name env var to avoid collisions with potential GitHub env vars. * Improve option descriptions. * Remove superfluous newline. * Make sure that everything is correctly indented.
1 parent 78fbefb commit 1fa7454

File tree

2 files changed

+127
-18
lines changed

2 files changed

+127
-18
lines changed

.github/workflows/ansible-release.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,32 @@ name: Release Ansible package
1111
description: >-
1212
Release Version. Example: 11.1.0
1313
required: true
14+
preserve-deps:
15+
description: >-
16+
Whether to preserve existing `.deps` files.
17+
type: boolean
18+
default: false
19+
allow-reset-build-deps:
20+
description: >-
21+
Whether to allow resetting existing `.build` files during alpha and beta-1 releases.
22+
23+
Should only be set to `false` for specific alpha or beta-1 releases if the deps and
24+
build files have been prepared manually.
25+
type: boolean
26+
default: true
27+
existing-branch:
28+
description: >-
29+
If provided, assumes that a branch of this name exists in the `ansible-build-data`
30+
repository. Changes will be pushed to this branch, and the PR will be created from
31+
it.
32+
type: string
33+
default: ''
1434
env:
1535
CI_COMMIT_MESSAGE: >-
1636
Ansible ${{ inputs.ansible-version }}:
1737
Dependencies, changelog and porting guide
1838
ANSIBLE_VERSION: ${{ inputs.ansible-version }}
39+
ANSIBLE_BRANCH_NAME: ${{ inputs.existing-branch || ('publish-' + inputs.ansible-version) }}
1940

2041
jobs:
2142
build:
@@ -38,11 +59,12 @@ jobs:
3859
- name: Pre-create build directory
3960
run: mkdir -p antsibull/build
4061

41-
# This is where the antsibull build-release role expects it by default
4262
- name: Check out ansible-build-data under antsibull build directory
4363
uses: actions/checkout@v4
4464
with:
65+
# This is where the antsibull build-release role expects it by default
4566
path: antsibull/build/ansible-build-data
67+
ref: ${{ inputs.existing-branch || '' }}
4668

4769
- name: Set up Python 3.11
4870
uses: actions/setup-python@v5
@@ -83,9 +105,10 @@ jobs:
83105
set_output('major-version', version.major)
84106
85107
- name: Checking out to a new branch
108+
if: inputs.existing-branch == ''
86109
working-directory: antsibull/build/ansible-build-data
87110
run: |
88-
git checkout -b "publish-${ANSIBLE_VERSION}"
111+
git checkout -b "${ANSIBLE_BRANCH_NAME}"
89112
90113
- name: Setting the user details
91114
run: |
@@ -96,13 +119,17 @@ jobs:
96119

97120
- name: Building a release with the defaults
98121
working-directory: antsibull
122+
env:
123+
PRESERVE_DEPS: ${{ inputs.preserve-deps }}
124+
ALLOW_RESET_BUILD_DEPS: ${{ inputs.allow-reset-build-deps }}
125+
# Make result better readable
126+
ANSIBLE_CALLBACK_RESULT_FORMAT: yaml
99127
run: >-
100128
ansible-playbook -vv playbooks/build-single-release.yaml
101129
-e antsibull_data_reset=false
130+
-e "antsibull_build_reset=${ALLOW_RESET_BUILD_DEPS}"
102131
-e "antsibull_ansible_version=${ANSIBLE_VERSION}"
103-
env:
104-
# Make result better readable
105-
ANSIBLE_CALLBACK_RESULT_FORMAT: yaml
132+
-e "antsibull_preserve_deps=${PRESERVE_DEPS}"
106133
107134
- name: Upload artifact
108135
uses: actions/upload-artifact@v4
@@ -115,9 +142,9 @@ jobs:
115142
working-directory: >-
116143
antsibull/build/ansible-build-data/${{ steps.extract-version.outputs.major-version }}
117144
run: |
118-
git add .
119-
git commit -m "${CI_COMMIT_MESSAGE}"
120-
git push origin "publish-${ANSIBLE_VERSION}"
145+
git add .
146+
git commit -m "${CI_COMMIT_MESSAGE}"
147+
git push origin "${ANSIBLE_BRANCH_NAME}"
121148
122149
- name: Create PR to the ansible-build-data
123150
id: create-pr
@@ -130,7 +157,7 @@ jobs:
130157
echo -n "pr_url=" >> "${GITHUB_OUTPUT}"
131158
gh pr create \
132159
--base main \
133-
--head "publish-${ANSIBLE_VERSION}" \
160+
--head "${ANSIBLE_BRANCH_NAME}" \
134161
--title "Release Ansible ${ANSIBLE_VERSION}" \
135162
--body "${body}" | tee -a "$GITHUB_OUTPUT"
136163

docs/automated-process.md

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,31 @@ release process. The automated processes uses GitHub Actions to automate the
1616

1717
1. Trigger [the automated
1818
workflow](https://github.com/ansible-community/ansible-build-data/actions/workflows/ansible-release.yml)
19-
on the **Actions** tab of the repository and specify the release version,
20-
such as `11.2.0` or `12.0.0rc1`. The process will create a PR in the
21-
[`ansible-build-data` repository](https://github.com/ansible-community/ansible-build-data/).
22-
Afterwards, it will wait for approval before continuing with uploading the
23-
package to PyPI. All users in the [ansible-community/release-management-wg
24-
group](https://github.com/orgs/ansible-community/teams/release-management-wg)[^1]
25-
will be informed with a notification once the approval is needed.
26-
The notification includes a link to the page where the upload step can be
27-
approved.
19+
on the **Actions** tab of the repository. This workflow has multiple inputs.
20+
The most important is the release version, such as `11.2.0` or `12.0.0rc1`.
21+
This always has to be specified.
22+
23+
The following additional inputs are required for special releases. Generally
24+
you do not need to pass them and can rely on their defaults. Cases where you
25+
need these inputs are described in the [Special builds](#special-builds)
26+
section below.
27+
28+
* You can optionally decide whether to preserve existing `.deps` files.
29+
The default is to regenerate them.
30+
* You can optionally decide whether the `.build` file should be regenerated
31+
during alpha and beta-1 releases.
32+
* You can also specify an existing branch in the [`ansible-build-data`
33+
repository](https://github.com/ansible-community/ansible-build-data/) to
34+
create the PR on.
35+
36+
The process will create a PR in the [`ansible-build-data`
37+
repository](https://github.com/ansible-community/ansible-build-data/).
38+
Afterwards, it will wait for approval before continuing with uploading the
39+
package to PyPI. All users in the [ansible-community/release-management-wg
40+
group](https://github.com/orgs/ansible-community/teams/release-management-wg)[^1]
41+
will be informed with a notification once the approval is needed.
42+
The notification includes a link to the page where the upload step can be
43+
approved.
2844

2945
2. Check out the PR in your `ansible-build-data` clone and copy the updated
3046
porting guide from its `${MAJOR_VERSION}` directory into the
@@ -53,3 +69,69 @@ release process. The automated processes uses GitHub Actions to automate the
5369
5470
[^1]: This group is configured as "Required reviewers" for the "Configure pypi"
5571
build environment in GitHub Actions of the `ansible-build-data` repository.
72+
73+
## Special builds
74+
75+
### Builds with a specific release summary other than the default one
76+
77+
Sometimes you want to use a different release summary than the default one.
78+
For example for the Ansible 9.5.1 release, we included some text that explained
79+
why the release has version 9.5.1 and not 9.5.0.
80+
81+
For this, create a new branch in `ansible-build-data`. Add a `release_summary`
82+
changelog entry for the new release to the `changelog.yaml` file in the major
83+
version's directory. Make sure to follow the same basic structure of the version's
84+
record in `changelog.yaml`. This can look as follows:
85+
```yaml
86+
releases:
87+
...
88+
12.3.4:
89+
changes:
90+
release_summary: |
91+
Release Date: 2024-05-14
92+
93+
Porting Guide <https://docs.ansible.com/ansible/devel/porting_guides.html>`_
94+
95+
This is a special release because of ...
96+
```
97+
98+
After that, you can start the automated workflow. You need to set the following option
99+
next to the release version:
100+
101+
1. Set `existing-branch` to the branch you pushed to the `ansible-build-data`
102+
repository.
103+
104+
### Additional release candidates (rc2 etc.)
105+
106+
For these release candidates, you only want to bump very specific collection
107+
versions, and not use new bugfix releases of potentially all included collections.
108+
109+
For this, create a new branch in `ansible-build-data` where you copy the `.deps`
110+
file of the previous release candidate to the location of the `.deps` file of the
111+
planned release. Then you modify the new `.deps` file with the version updates
112+
you plan to make.
113+
114+
After that, you can start the automated workflow. You need to set the following options
115+
next to the release version:
116+
117+
1. Set `preserve-deps` to `true`;
118+
119+
2. Set `existing-branch` to the branch you pushed to the `ansible-build-data`
120+
repository.
121+
122+
### New major release (x.0.0)
123+
124+
The new major release should include exactly the same dependencies as the last
125+
release candidate.
126+
127+
For this, create a new branch in `ansible-build-data` where you copy the `.deps`
128+
file of the last release candidate to the location of the `.deps` file of the
129+
planned major release. Do not modify the new `.deps` file with any version updates.
130+
131+
After that, you can start the automated workflow. You need to set the following options
132+
next to the release version:
133+
134+
1. Set `preserve-deps` to `true`;
135+
136+
2. Set `existing-branch` to the branch you pushed to the `ansible-build-data`
137+
repository.

0 commit comments

Comments
 (0)