Remove release test harness and document the release process
Build and release ELOG / Windows x64 (push) Failing after 2s
Build and release ELOG / EL10 (push) Successful in 1m23s
Build and release ELOG / EL9 (push) Successful in 1m25s
Build and release ELOG / EL8 (push) Successful in 1m55s
Build and release ELOG / Container and release (push) Skipped
Build and release ELOG / Windows x64 (pull_request) Failing after 1s
Build and release ELOG / EL9 (pull_request) Successful in 5s
Build and release ELOG / EL10 (pull_request) Successful in 5s
Build and release ELOG / EL8 (pull_request) Successful in 5s
Build and release ELOG / Container and release (pull_request) Skipped

This commit is contained in:
bruhn_b committed 2026-11-23 18:48:18 +01:00
1 parent dc5814211a
commit 33f8ea7064
3 files changed
+91 -177

No files matched your search

-3
View File
@@ -20,9 +20,6 @@ jobs:
with:
submodules: recursive
persist-credentials: false
- name: Test release publishing against a local API
if: matrix.el == 9
run: python3 -m unittest discover -s tests -p test_release.py
- name: Read version
id: version
env:
+91 -25
View File
@@ -10,45 +10,111 @@ Everything is built by `.gitea/workflows/build.yml`:
Builds and runtime dependencies use public Rocky repositories; no private
RHEL image or PSI package mirror is required.
ELOG itself is compiled from this checkout, including the pinned `mxml`
submodule. The container installs that newly built RPM. Gitea supplies the
source, Actions and release hosting; Docker Hub and public Rocky mirrors supply
the base images, compilers and system libraries. `repos.psi.ch` was used by the
previous private RHEL image and is no longer used by this workflow.
Every build starts ELOG and checks its HTTP response. Branches, pull requests and
manual runs validate the build and retain downloads for 30 days. **Only version
tag pushes publish packages or create release drafts.**
## Make a release
## What triggers publishing?
1. Update `src/elog-version.h` and the first version section in `doc/ChangeLog`.
Use patch versions for fixes, minor versions for compatible features and major
versions for breaking changes.
2. Tag the reviewed commit with the matching version and push it:
| Action | Result |
| --- | --- |
| Push a branch, open a pull request or start a manual run | Build and check the packages and container; retain CI downloads for 30 days. |
| Push a matching version tag, such as `v3.1.7` | Run all builds and checks, then publish versioned packages and prepare a Gitea release draft. |
| Click **Publish release** in Gitea | Make the release page public to readers of the repository. Packages are already published; no build or deployment is started. |
```sh
git tag -a v3.1.6 -m "ELOG 3.1.6"
git push origin v3.1.6
Developers own functional validation and release approval, using the project's
usual review process. CI retains the build, installation and HTTP checks.
`.gitea/scripts/release.py` handles the uploads and release draft.
## Full example: release 3.1.7
Assume this repository has moved to `elog/elog`, its default branch is `master`,
and the setup below is complete. These are example commands, not a release that
has already been created.
1. Prepare the version and release notes through the project's usual change and
review process. Change `src/elog-version.h` to:
```c
#define VERSION "3.1.7"
```
3. After all Linux and Windows checks pass, CI publishes the versioned container
and RPMs, and creates a **draft Gitea Release**. The draft contains the Windows
ZIP, RPMs, source RPMs, a source archive including `mxml`, checksums, the image
digest and notes from `doc/ChangeLog`. Review the notes and publish the draft.
Prepend a section to `doc/ChangeLog`, retaining the older entries:
The tag must match the source version exactly. Prerelease tags are not supported.
Protect `v*` tags and never move a released tag. After releasing, bump the source
version for the next development cycle. Snapshot RPMs use release
`0.<commit timestamp>.git<sha>`; tagged RPMs use release `1`.
```text
Version 3.1.7, released November 23rd, 2026
==========================================
- Build Linux and Windows packages with Gitea Actions.
- Use a public Rocky Linux base for the container.
```
Use the actual release date and changes. Merge the reviewed change as usual.
2. Tag the reviewed commit on the default branch:
```sh
git switch master
git pull --ff-only
git tag -a v3.1.7 -m "ELOG 3.1.7"
git push origin v3.1.7
```
Pushing the tag authorizes package publication. The tag must match the source
version exactly; a mismatch fails the build. An ordinary branch push does
not publish packages.
3. Wait for the tag's Actions run to finish. CI builds and checks EL8, EL9 and
EL10 RPMs plus the Windows ZIP. It then builds the container from the checked
EL9 RPM and checks its HTTP response. After those checks pass, the publishing
helper creates a draft, pushes the versioned image, attaches the downloads
and uploads the RPMs to the organization's package registry.
For this example the results are:
| Output | Location/name |
| --- | --- |
| Container | `gitea.psi.ch/elog/elog:3.1.7` |
| Native RPMs | `elog-3.1.7-1.el8.x86_64.rpm`, plus EL9 and EL10 equivalents |
| Source RPMs | `elog-3.1.7-1.el8.src.rpm`, plus EL9 and EL10 equivalents |
| Source archive, including `mxml` | `elog-3.1.7-1.tar.gz` |
| Windows download | `elog-3.1.7-windows-x64.zip` |
| Integrity/provenance | `SHA256SUMS` and `image.txt` containing the image digest |
| RPM repositories | `https://gitea.psi.ch/api/packages/elog/rpm/el9.repo`, plus `el8` and `el10` |
4. Open **Releases** in the repository. Wait for the publishing job to succeed,
review the **ELOG 3.1.7** draft, its notes and attached files, then click
**Publish release**. Notes are initially taken from the first section of
`doc/ChangeLog`.
The image and RPMs become available during step 3, before this manual step.
Publishing the draft does not promote `latest` or restart any installation.
Update deployments separately to use `gitea.psi.ch/elog/elog:3.1.7` or its
recorded digest. If you also maintain `latest`, promote it explicitly after
reviewing the release:
```sh
docker login gitea.psi.ch
docker buildx imagetools create \
--tag gitea.psi.ch/elog/elog:latest \
gitea.psi.ch/elog/elog:3.1.7
```
Protect `v*` tags and never move a released tag. Prerelease tags are not
supported. Snapshot RPMs use release `0.<commit timestamp>.git<sha>`; tagged RPMs
use release `1`. Bump the source version for the next development cycle when
appropriate so its snapshots sort after the previous stable release.
Published releases are never edited by CI. A failed publishing job can resume a
draft when its artifacts are identical; conflicting files fail instead of being
replaced. Rerun the failed publishing job using the original build artifacts.
`latest` is optional and stays a deliberate promotion of a reviewed release:
```sh
organization=your-org
docker buildx imagetools create \
--tag "gitea.psi.ch/$organization/elog:latest" \
"gitea.psi.ch/$organization/elog:3.1.6"
```
## Gitea setup
The publishing paths follow the repository automatically. For `my-org/elog`:
-149
View File
@@ -1,149 +0,0 @@
"""Exercise publishing against a local Gitea API stand-in; Docker is mocked."""
import hashlib
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import importlib.util
import json
import os
from pathlib import Path
import tempfile
import threading
import unittest
from unittest.mock import patch
from email.parser import BytesParser
from email.policy import default
spec = importlib.util.spec_from_file_location("release", Path(__file__).parents[1] / ".gitea/scripts/release.py")
release = importlib.util.module_from_spec(spec)
spec.loader.exec_module(release)
class ReleaseTest(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.directory = Path(self.temp.name)
previous_directory = Path.cwd()
self.addCleanup(os.chdir, previous_directory)
os.chdir(self.directory)
(self.directory / "doc").mkdir()
(self.directory / "doc/ChangeLog").write_text("Version 3.1.6, released for this test\n- Fixture release notes\n")
for target in ("el8", "el9", "el10", "windows"):
root = self.directory / target
names = ([f"RPMS/elog-3.1.6-1.{target}.x86_64.rpm", f"SRPMS/elog-3.1.6-1.{target}.src.rpm"]
if target != "windows" else ["elog-3.1.6-windows-x64.zip"])
if target == "el9":
names.append("SOURCES/elog-3.1.6-1.tar.gz")
for name in names:
file = root / name
file.parent.mkdir(parents=True, exist_ok=True)
file.write_bytes(name.encode())
(root / "SHA256SUMS").write_text("".join(
f"{hashlib.sha256((root / name).read_bytes()).hexdigest()} {name}\n" for name in names))
self.draft = None
self.assets = {}
self.rpms = {}
self.writes = 0
test = self
class Handler(BaseHTTPRequestHandler):
def parse_request(self):
valid = super().parse_request()
if valid:
test.assertEqual(self.headers.get("Authorization"), "token test-token")
return valid
def log_message(self, *args):
pass
def reply(self, code, data):
self.send_response(code)
self.end_headers()
self.wfile.write(data if isinstance(data, bytes) else json.dumps(data).encode())
def do_GET(self):
if self.path.startswith("/asset/"):
return self.reply(200, test.assets[self.path.removeprefix("/asset/")])
if self.path.endswith("/releases/tags/v3.1.6"):
return self.reply(200, test.draft) if test.draft else self.reply(404, {})
if self.path.endswith("/assets"):
return self.reply(200, [{"name": name, "browser_download_url": test.server_url + "/asset/" + name}
for name in test.assets])
if "/packages/new-org/rpm/elog/" in self.path:
test.assertRegex(self.path, r"^/api/v1/packages/new-org/rpm/elog/3\.1\.6-1\.el(8|9|10)/files$")
version = self.path.split("/")[-2]
return self.reply(200, [{"sha256": hashlib.sha256(data).hexdigest()}
for name, data in test.rpms.items() if f"elog-{version}." in name])
self.reply(404, {})
def do_POST(self):
test.writes += 1
body = self.rfile.read(int(self.headers["Content-Length"]))
if self.path.endswith("/releases"):
test.draft = {**json.loads(body), "id": 1, "html_url": test.server_url + "/release/1"}
return self.reply(201, test.draft)
message = BytesParser(policy=default).parsebytes(
f"Content-Type: {self.headers['Content-Type']}\r\n\r\n".encode() + body)
attachment = next(message.iter_attachments())
name = attachment.get_filename()
test.assertNotIn(name, test.assets, "Release assets must not be overwritten")
test.assets[name] = attachment.get_payload(decode=True)
self.reply(201, {})
def do_PUT(self):
test.writes += 1
test.assertRegex(self.path, r"^/api/packages/new-org/rpm/el(8|9|10)/upload$")
data = self.rfile.read(int(self.headers["Content-Length"]))
name = data.decode() # Fixture contents identify the RPM.
if name in test.rpms:
return self.reply(409, {})
test.rpms[name] = data
self.reply(201, {})
self.server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
self.server_url = f"http://127.0.0.1:{self.server.server_port}"
threading.Thread(target=self.server.serve_forever, daemon=True).start()
self.addCleanup(self.server.server_close)
self.addCleanup(self.server.shutdown)
env = {"SERVER_URL": self.server_url, "REPOSITORY": "new-org/elog", "VERSION": "3.1.6",
"PUBLISH_USER": "publisher", "PUBLISH_TOKEN": "test-token"}
self.addCleanup(patch.stopall)
patch.dict(os.environ, env).start()
self.docker = patch.object(release.subprocess, "run").start()
patch.object(release.subprocess, "check_output", return_value=b"image@sha256:example\n").start()
def test_publish_and_retry_draft_in_new_organization(self):
release.publish(self.directory, "elog:test")
self.assertTrue(self.draft["draft"])
self.assertEqual(len(self.rpms), 6)
self.assertEqual(len(self.assets), 10)
self.assertTrue(any("new-org/elog:3.1.6" in call.args[0][-1] for call in self.docker.call_args_list))
for line in self.assets["SHA256SUMS"].decode().splitlines():
expected, name = line.split(maxsplit=1)
self.assertEqual(expected, hashlib.sha256(self.assets[name]).hexdigest())
release.publish(self.directory, "elog:test")
self.assertEqual(len(self.rpms), 6)
self.assertEqual(len(self.assets), 10)
def test_bad_checksum_stops_before_publishing(self):
next((self.directory / "el9/RPMS").glob("*.rpm")).write_bytes(b"corrupt")
with self.assertRaisesRegex(ValueError, "Checksum mismatch"):
release.publish(self.directory, "elog:test")
self.assertEqual(self.writes, 0)
self.docker.assert_not_called()
def test_conflicting_registry_package_is_rejected(self):
release.publish(self.directory, "elog:test")
self.rpms[next(iter(self.rpms))] = b"different RPM in registry"
with self.assertRaisesRegex(ValueError, "Existing registry RPM differs"):
release.publish(self.directory, "elog:test")
def test_published_release_is_untouched(self):
self.draft = {"draft": False, "id": 1}
with self.assertRaisesRegex(ValueError, "already published"):
release.publish(self.directory, "elog:test")
self.assertEqual(self.writes, 0)
self.docker.assert_not_called()
if __name__ == "__main__":
unittest.main()