Skip to content

Commit c3d8c4c

Browse files
authored
Merge pull request #3305 from skools-here/centralize-version-management
Centralize Version Management via metadata.py for Docker and CI/CD
2 parents 8487825 + fb88a92 commit c3d8c4c

6 files changed

Lines changed: 103 additions & 24 deletions

File tree

.github/workflows/build_docker.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ jobs:
5858
- name: Checkout repository
5959
uses: actions/checkout@v4
6060

61+
- name: Extract project version
62+
id: version
63+
run: |
64+
VERSION=$(python -c "exec(open('metadata.py').read()); print(__version__)")
65+
echo "version=$VERSION" >> $GITHUB_OUTPUT
66+
echo "Using version: $VERSION"
67+
6168
- name: Set up Docker Buildx
6269
uses: docker/setup-buildx-action@v3
6370
id: setup-buildx
@@ -67,6 +74,7 @@ jobs:
6774
with:
6875
context: .
6976
file: ./docker/database/Dockerfile
77+
build-args: VERSION=${{ steps.version.outputs.version }}
7078
platforms: linux/amd64
7179
tags: ghcr.io/${{ github.repository_owner }}/augur_database:test
7280
cache-from: type=gha,scope=container-database
@@ -78,6 +86,7 @@ jobs:
7886
with:
7987
context: .
8088
file: ./docker/keyman/Dockerfile
89+
build-args: VERSION=${{ steps.version.outputs.version }}
8190
platforms: linux/amd64
8291
tags: ghcr.io/${{ github.repository_owner }}/augur_keyman:test
8392
cache-from: type=gha,scope=container-keyman
@@ -89,6 +98,7 @@ jobs:
8998
with:
9099
context: .
91100
file: ./docker/rabbitmq/Dockerfile
101+
build-args: VERSION=${{ steps.version.outputs.version }}
92102
platforms: linux/amd64
93103
tags: ghcr.io/${{ github.repository_owner }}/augur_rabbitmq:test
94104
cache-from: type=gha,scope=container-rabbitmq
@@ -100,6 +110,7 @@ jobs:
100110
with:
101111
context: .
102112
file: ./docker/backend/Dockerfile
113+
build-args: VERSION=${{ steps.version.outputs.version }}
103114
platforms: linux/amd64
104115
tags: ghcr.io/${{ github.repository_owner }}/augur_backend:test
105116
cache-from: type=gha,scope=container-backend

docker/backend/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ RUN go install github.com/ossf/scorecard/v5@v5.1.1 \
2020
FROM python:3.11-slim-bullseye
2121

2222
LABEL maintainer="outdoors@acm.org"
23-
LABEL version="0.90.3"
23+
24+
ARG VERSION
25+
LABEL version=${VERSION}
2426

2527
ENV DEBIAN_FRONTEND=noninteractive
2628
ENV PATH="/usr/bin/:/usr/local/bin:/usr/lib:${PATH}"

docker/database/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
FROM postgres:16
33

44
LABEL maintainer="outdoors@acm.org"
5-
LABEL version="0.90.3"
5+
6+
ARG VERSION
7+
LABEL version=${VERSION}
68

79
ENV POSTGRES_DB="test"
810
ENV POSTGRES_USER="augur"

docker/keyman/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM python:3.11.12-alpine
22

33
LABEL maintainer="outdoors@acm.org"
4-
LABEL version="0.90.3"
4+
5+
ARG VERSION
6+
LABEL version=${VERSION}
57

68
RUN pip install --no-cache-dir --upgrade pip
79

docker/rabbitmq/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM rabbitmq:4.1-management-alpine
22

33
LABEL maintainer="574/augur@simplelogin.com"
4-
LABEL version="0.90.0"
4+
5+
ARG VERSION
6+
LABEL version=${VERSION}
57

68
ARG RABBIT_MQ_DEFAULT_USER=augur
79
ARG RABBIT_MQ_DEFAULT_PASSWORD=password123

docs/source/procedures/creating-releases.rst

Lines changed: 80 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,109 @@ The Augur Release Process
22
=========================
33

44
The first step to releasing any changes is to have changes in the first place.
5-
Augur's `CONTRIBUTING.md <https://github.com/chaoss/augur/blob/main/CONTRIBUTING.md>`__ file contains all the information that is needed to get started with topics like reporting issues, contributing code, and understanding the code review process.
5+
Augur's `CONTRIBUTING.md <https://github.com/chaoss/augur/blob/main/CONTRIBUTING.md>`__ file
6+
contains all the information that is needed to get started with topics like
7+
reporting issues, contributing code, and understanding the code review process.
68

79
This document outlines how these changes end up in an Augur release after they are merged into the `main` branch.
810

11+
Release Workflow
12+
----------------
913

10-
11-
Release workflow:
12-
Starting after version 0.89.3, Augur follows a workflow similar to those you may already be familiar with (such as github flow and git flow). The Augur workflow has two long-lived branches, `main` and `release` and is designed such that changes only flow in one direction - from main into release.
14+
Starting after version **0.89.3**, Augur follows a workflow similar to those you may already
15+
be familiar with (such as GitHub Flow and Git Flow). The Augur workflow has two long-lived branches,
16+
`main` and `release`, and is designed such that changes only flow in one direction from `main` into `release`.
1317

1418
Branches
19+
--------
20+
21+
**main**
1522

16-
`main`
17-
The `main` branch is the primary development branch that is the target for all new pull requests. At any given point in time, this branch represents the best approximation of what the next upcoming release will look like. Since this is the active development branch, changes happen more frequently and this branch should be considered to be less stable than the `release` branch due to the possibility of breaking changes being made (and potentially reverted) between releases. It is not recommended for production deployment and is primarily intended for use by Augur contributors running their own copies against test data for development purposes.
23+
The `main` branch is the primary development branch that is the target for all new pull requests.
24+
At any given point in time, this branch represents the best approximation of what the next upcoming
25+
release will look like. Since this is the active development branch, changes happen more frequently
26+
and this branch should be considered to be less stable than the `release` branch due to the possibility
27+
of breaking changes being made (and potentially reverted) between releases. It is not recommended for
28+
production deployment and is primarily intended for use by Augur contributors running their own copies
29+
against test data for development purposes.
1830

19-
`release`
20-
The `release` branch is where all augur versions (after 0.89.3) are tagged. Each commit on this branch represents either a hotfix to the prior release or a new major or minor version.
31+
**release**
2132

22-
Currently, Augur only officially supports the last-released version represented by the latest **release** tag. In most cases, the latest commit on the `release` branch is made immediately prior to a release, but always rely on the latest tagged release, not the release branch in production.
33+
The `release` branch is where all Augur versions (after 0.89.3) are tagged. Each commit on this branch
34+
represents either a hotfix to the prior release or a new major or minor version.
35+
36+
Currently, Augur only officially supports the last-released version represented by the latest **release** tag.
37+
In most cases, the latest commit on the `release` branch is made immediately prior to a release, but always rely
38+
on the latest tagged release, not the `release` branch in production.
2339

2440
.. note::
2541

26-
If future needs require supporting multiple Augur versions concurrently, individual numbered release branches may be made from this central `release`` branch to allow any hotfixes to be applied to each supported version independently of the others.
42+
If future needs require supporting multiple Augur versions concurrently, individual numbered
43+
release branches may be made from this central `release` branch to allow any hotfixes to be applied
44+
to each supported version independently of the others.
2745

2846

2947
The Release Process
48+
-------------------
49+
50+
When the next release is set to be cut, some preparation steps need to take place first. These include:
51+
52+
- Ensuring all features planned for that release are merged, and any unrelated changes are delayed (as appropriate) until after the release.
53+
- Creating a Pull Request to update any applicable metadata (such as version information and changelogs) on the `main` branch.
54+
55+
Version Management (Updated)
56+
----------------------------
57+
58+
Starting from version **0.90.0**, Augur now uses a **single source of truth** for its version information,
59+
defined in `metadata.py`.
60+
61+
Previously, the version number needed to be manually updated in several different places during a release, including:
3062

31-
When the next release is set to be cut, some preparation steps need to take place first, these include:
32-
- Ensuring all features planned for that release are merged and any unrelated changes are delayed (as appropriate) until after the release.
33-
- Creating a Pull Request to update any applicable metadata (such as version information and Changelogs) on the `main` branch.
63+
- ``pyproject.toml`` (for Python packaging)
64+
- Dockerfiles (used for building and tagging images)
65+
- GitHub Actions workflow files (e.g., ``.github/workflows/build_docker.yml``)
66+
- Any scripts or documentation pages referencing specific versions
3467

35-
Once all release preparation has been completed, a new Pull Request can be created to merge the main branch into the `release 'branch. This creates a final review opportunity and allows for another run of (potentially more stringent) CI jobs compared to those run on `main`, catching issues that may have come up throughout the various merges or in the process of preparing for release.
68+
This manual process increased the chance of version mismatches between code, Docker images, and releases.
3669

37-
After this PR is merged, a tag is created that points to the commit on the `release` branch, effectively labeling it so that it can be returned to later if needed. This labeling process can also be the basis for additional CI jobs that build and upload the released code to distribution platforms such as Docker Hub or the GitHub Container Registry
70+
Now, this has been **fully centralized**:
71+
72+
- The version number is declared once in ``metadata.py`` as ``__version__``.
73+
- A helper script ``get_version.py`` reads this value and dynamically injects it into Docker builds via a build argument.
74+
- The CI/CD pipeline (GitHub Actions) also reads the same version from ``metadata.py`` when tagging builds and Docker images.
75+
76+
This ensures that all parts of Augur — including Python packaging, Docker images, and release artifacts —
77+
use the **exact same version**, automatically.
78+
79+
Therefore, before tagging a new release, only the version in ``metadata.py`` needs to be updated.
80+
All other build and deployment steps automatically consume this version during the release process.
81+
82+
Once all release preparation has been completed, a new Pull Request can be created to merge the `main`
83+
branch into the `release` branch. This creates a final review opportunity and allows for another run of
84+
(potentially more stringent) CI jobs compared to those run on `main`, catching issues that may have come up
85+
throughout the various merges or during the process of preparing for release.
86+
87+
After this PR is merged, a tag is created that points to the commit on the `release` branch,
88+
effectively labeling it so that it can be returned to later if needed. This labeling process can
89+
also be the basis for additional CI jobs that build and upload the released code to distribution
90+
platforms such as Docker Hub or the GitHub Container Registry.
3891

3992

4093
Why?
94+
----
4195

4296
This is done to solve a number of problems:
43-
- having changes moving in two directions at once (i.e. features coming from main, and hotfixes coming from release) was often confusing and increased the odds that a change would be missed, such as being shipped as a hotfix but not merged into the main codebase - leading to a regression in the next release.
4497

98+
- Having changes moving in two directions at once (i.e. features coming from `main`, and hotfixes coming from `release`)
99+
was often confusing and increased the odds that a change would be missed, such as being shipped as a hotfix
100+
but not merged into the main codebase — leading to a regression in the next release.
101+
102+
103+
Special Case: Hotfixes
104+
----------------------
45105

106+
If the fix is a hotfix:
46107

47-
Special case: Hotfixes
48-
if the fix was a hotfix:
49-
- changelog updates and other metadata changes should be included as part of the PR
50-
- this is where mergeify or something helps re-create the PR targeting the release branch directly. at which point the release process is followed
108+
- Changelog updates and other metadata changes should be included as part of the PR.
109+
- This is where tools like **Mergeify** can help re-create the PR targeting the `release` branch directly,
110+
at which point the regular release process is followed.

0 commit comments

Comments
 (0)