BlueGit

ict rusty-teams

ci(release): nightly pre-release of main

- nightly.yml tags v<next minor>.0-nightly.<UTC yyyymmddhhmm> at 02:23 UTC and dispatches build.yml for it
- Skips a day without new commits, keeps the newest seven nightlies
- Nightly notes list every change since the last release
- README says how nightlies update

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-27 · 4 days ago

Hash
7059d5effcac0e772e2ec05d085863be8b0fa377
Parent
c97fe26f
5 files changed +146 −2
.github/scripts/nightly.py added +72 −0
@@ -0,0 +1,72 @@
1 """Tags main as a nightly pre-release and starts build.yml for it (.github/workflows/nightly.yml).
2
3 Tag: v<next minor>.0-nightly.<UTC yyyymmddhhmm>. It sorts above the last release and below the next
4 one (release_feed.rs), so a nightly install moves on to the next release on its own. Only a build
5 that runs a pre-release is offered pre-releases, so stable installs never see nightlies.
6 """
7
8 import datetime
9 import json
10 import re
11 import subprocess
12 import sys
13 import urllib.parse
14
15 STABLE_TAG = re.compile(r"^v(\d+)\.(\d+)\.(\d+)$")
16 NIGHTLY_TAG = re.compile(r"^v\d+\.\d+\.\d+-nightly\.\d{12}$")
17 KEEP_NIGHTLIES = 7
18 BUILD_WORKFLOW = "build.yml"
19
20
21 def next_version(tags: list[str]) -> str:
22 stable = [tuple(map(int, match.groups())) for match in map(STABLE_TAG.match, tags) if match]
23 major, minor, _ = max(stable, default=(0, 0, 0))
24 return f"{major}.{minor + 1}.0"
25
26
27 def nightly_tag(tags: list[str], now: datetime.datetime) -> str:
28 return f"v{next_version(tags)}-nightly.{now.strftime('%Y%m%d%H%M')}"
29
30
31 def stale_nightlies(tags: list[str], keep: int = KEEP_NIGHTLIES) -> list[str]:
32 nightlies = sorted((tag for tag in tags if NIGHTLY_TAG.match(tag)), key=lambda tag: tag.rsplit(".", 1)[1])
33 return nightlies[:-keep] if keep else nightlies
34
35
36 def run(*command: str) -> str:
37 return subprocess.run(command, check=True, capture_output=True, text=True).stdout.strip()
38
39
40 def gh_api(method: str, path: str, *fields: str) -> str:
41 return run("gh", "api", "-X", method, path, *fields)
42
43
44 def delete_nightly(repository: str, tag: str) -> None:
45 try:
46 release = json.loads(gh_api("GET", f"repos/{repository}/releases/tags/{urllib.parse.quote(tag)}"))
47 gh_api("DELETE", f"repos/{repository}/releases/{release['id']}")
48 except subprocess.CalledProcessError:
49 pass
50 run("git", "push", "--delete", "origin", tag)
51
52
53 def main() -> int:
54 repository = run("gh", "repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner")
55 if any(NIGHTLY_TAG.match(tag) for tag in run("git", "tag", "--points-at", "HEAD").split()):
56 print("main has not moved since the last nightly")
57 return 0
58 tags = run("git", "tag", "--list", "v*").split()
59 tag = nightly_tag(tags, datetime.datetime.now(datetime.timezone.utc))
60 run("git", "tag", tag)
61 run("git", "push", "origin", tag)
62 # A tag pushed with the workflow token starts no workflow; a dispatch does.
63 run("gh", "workflow", "run", BUILD_WORKFLOW, "--ref", tag)
64 print(f"started {BUILD_WORKFLOW} for {tag}")
65 for stale in stale_nightlies(tags + [tag]):
66 delete_nightly(repository, stale)
67 print(f"deleted {stale}")
68 return 0
69
70
71 if __name__ == "__main__":
72 sys.exit(main())
@@ -0,0 +1,72 @@
1"""Tags main as a nightly pre-release and starts build.yml for it (.github/workflows/nightly.yml).
2
3Tag: v<next minor>.0-nightly.<UTC yyyymmddhhmm>. It sorts above the last release and below the next
4one (release_feed.rs), so a nightly install moves on to the next release on its own. Only a build
5that runs a pre-release is offered pre-releases, so stable installs never see nightlies.
6"""
7
8import datetime
9import json
10import re
11import subprocess
12import sys
13import urllib.parse
14
15STABLE_TAG = re.compile(r"^v(\d+)\.(\d+)\.(\d+)$")
16NIGHTLY_TAG = re.compile(r"^v\d+\.\d+\.\d+-nightly\.\d{12}$")
17KEEP_NIGHTLIES = 7
18BUILD_WORKFLOW = "build.yml"
19
20
21def next_version(tags: list[str]) -> str:
22 stable = [tuple(map(int, match.groups())) for match in map(STABLE_TAG.match, tags) if match]
23 major, minor, _ = max(stable, default=(0, 0, 0))
24 return f"{major}.{minor + 1}.0"
25
26
27def nightly_tag(tags: list[str], now: datetime.datetime) -> str:
28 return f"v{next_version(tags)}-nightly.{now.strftime('%Y%m%d%H%M')}"
29
30
31def stale_nightlies(tags: list[str], keep: int = KEEP_NIGHTLIES) -> list[str]:
32 nightlies = sorted((tag for tag in tags if NIGHTLY_TAG.match(tag)), key=lambda tag: tag.rsplit(".", 1)[1])
33 return nightlies[:-keep] if keep else nightlies
34
35
36def run(*command: str) -> str:
37 return subprocess.run(command, check=True, capture_output=True, text=True).stdout.strip()
38
39
40def gh_api(method: str, path: str, *fields: str) -> str:
41 return run("gh", "api", "-X", method, path, *fields)
42
43
44def delete_nightly(repository: str, tag: str) -> None:
45 try:
46 release = json.loads(gh_api("GET", f"repos/{repository}/releases/tags/{urllib.parse.quote(tag)}"))
47 gh_api("DELETE", f"repos/{repository}/releases/{release['id']}")
48 except subprocess.CalledProcessError:
49 pass
50 run("git", "push", "--delete", "origin", tag)
51
52
53def main() -> int:
54 repository = run("gh", "repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner")
55 if any(NIGHTLY_TAG.match(tag) for tag in run("git", "tag", "--points-at", "HEAD").split()):
56 print("main has not moved since the last nightly")
57 return 0
58 tags = run("git", "tag", "--list", "v*").split()
59 tag = nightly_tag(tags, datetime.datetime.now(datetime.timezone.utc))
60 run("git", "tag", tag)
61 run("git", "push", "origin", tag)
62 # A tag pushed with the workflow token starts no workflow; a dispatch does.
63 run("gh", "workflow", "run", BUILD_WORKFLOW, "--ref", tag)
64 print(f"started {BUILD_WORKFLOW} for {tag}")
65 for stale in stale_nightlies(tags + [tag]):
66 delete_nightly(repository, stale)
67 print(f"deleted {stale}")
68 return 0
69
70
71if __name__ == "__main__":
72 sys.exit(main())
.github/scripts/test_nightly.py added +31 −0
@@ -0,0 +1,31 @@
1 import datetime
2 import unittest
3
4 from nightly import nightly_tag, next_version, stale_nightlies
5
6 NOW = datetime.datetime(2026, 11, 27, 3, 5, tzinfo=datetime.timezone.utc)
7
8
9 class VersionTests(unittest.TestCase):
10 def test_next_minor_of_the_newest_release(self):
11 tags = ["v0.5.0", "v0.6.1", "v0.6.0", "v0.3.0-joe.9", "v0.7.0-nightly.202611260300"]
12 self.assertEqual(next_version(tags), "0.7.0")
13 self.assertEqual(nightly_tag(tags, NOW), "v0.7.0-nightly.202611270305")
14
15 def test_minor_sorts_as_a_number(self):
16 self.assertEqual(next_version(["v0.9.0", "v0.10.0"]), "0.11.0")
17
18 def test_a_release_candidate_is_not_a_release(self):
19 self.assertEqual(next_version(["v0.6.1", "v0.7.0-rc.1"]), "0.7.0")
20
21
22 class PruneTests(unittest.TestCase):
23 def test_keeps_the_newest_nightlies_and_nothing_else_is_touched(self):
24 nightlies = [f"v0.7.0-nightly.2026112{day}0300" for day in range(10)]
25 tags = ["v0.6.1", "v0.7.0-rc.1", "v0.8.0-nightly.202611300300", *nightlies]
26 stale = stale_nightlies(tags, keep=3)
27 self.assertEqual(stale, nightlies[:8])
28
29
30 if __name__ == "__main__":
31 unittest.main()
@@ -0,0 +1,31 @@
1import datetime
2import unittest
3
4from nightly import nightly_tag, next_version, stale_nightlies
5
6NOW = datetime.datetime(2026, 11, 27, 3, 5, tzinfo=datetime.timezone.utc)
7
8
9class VersionTests(unittest.TestCase):
10 def test_next_minor_of_the_newest_release(self):
11 tags = ["v0.5.0", "v0.6.1", "v0.6.0", "v0.3.0-joe.9", "v0.7.0-nightly.202611260300"]
12 self.assertEqual(next_version(tags), "0.7.0")
13 self.assertEqual(nightly_tag(tags, NOW), "v0.7.0-nightly.202611270305")
14
15 def test_minor_sorts_as_a_number(self):
16 self.assertEqual(next_version(["v0.9.0", "v0.10.0"]), "0.11.0")
17
18 def test_a_release_candidate_is_not_a_release(self):
19 self.assertEqual(next_version(["v0.6.1", "v0.7.0-rc.1"]), "0.7.0")
20
21
22class PruneTests(unittest.TestCase):
23 def test_keeps_the_newest_nightlies_and_nothing_else_is_touched(self):
24 nightlies = [f"v0.7.0-nightly.2026112{day}0300" for day in range(10)]
25 tags = ["v0.6.1", "v0.7.0-rc.1", "v0.8.0-nightly.202611300300", *nightlies]
26 stale = stale_nightlies(tags, keep=3)
27 self.assertEqual(stale, nightlies[:8])
28
29
30if __name__ == "__main__":
31 unittest.main()
.github/workflows/build.yml +6 −1
@@ -6,6 +6,7 @@ name: Build
6 6
7 7 # Builds run for tags (the release assets); pushes are tested in test.yml.
8 8 # A `v*` tag also publishes a GitHub release; a tag with `-` (v0.2.0-rc.1) is a pre-release.
9 # nightly.yml starts it with workflow_dispatch on a nightly tag.
9 10 on:
10 11 push:
11 12 tags: ['*']
@@ -248,7 +249,11 @@ jobs:
248 249 highlights="$(git log -1 --format=%b "$TAG" | grep -v -e '^Co-Authored-By:' -e 'Workspace version' | sed '/./,$!d' || true)"
249 250 # Notes must never block publishing the assets.
250 251 if ! {
251 if [[ -n "${highlights//[[:space:]]/}" ]]; then
252 # cliff.toml's tag_pattern skips nightly tags: a nightly lists everything since the last release.
253 if [[ "$TAG" == *-nightly.* ]]; then
254 printf 'Nightly build of main at %s. Not a release.\n\n' "$(git rev-parse --short "$TAG")"
255 "$cliff" --config cliff.toml --unreleased --strip all
256 elif [[ -n "${highlights//[[:space:]]/}" ]]; then
252 257 printf '## Highlights\n\n%s\n\n<details>\n<summary>All changes</summary>\n\n' "$highlights"
253 258 "$cliff" --config cliff.toml --current --strip all
254 259 printf '\n</details>\n'
@@ -6,6 +6,7 @@ name: Build
6
6
7# Builds run for tags (the release assets); pushes are tested in test.yml.
7# Builds run for tags (the release assets); pushes are tested in test.yml.
8# A `v*` tag also publishes a GitHub release; a tag with `-` (v0.2.0-rc.1) is a pre-release.
8# A `v*` tag also publishes a GitHub release; a tag with `-` (v0.2.0-rc.1) is a pre-release.
9# nightly.yml starts it with workflow_dispatch on a nightly tag.
9on:
10on:
10 push:
11 push:
11 tags: ['*']
12 tags: ['*']
@@ -248,7 +249,11 @@ jobs:
248 highlights="$(git log -1 --format=%b "$TAG" | grep -v -e '^Co-Authored-By:' -e 'Workspace version' | sed '/./,$!d' || true)"
249 highlights="$(git log -1 --format=%b "$TAG" | grep -v -e '^Co-Authored-By:' -e 'Workspace version' | sed '/./,$!d' || true)"
249 # Notes must never block publishing the assets.
250 # Notes must never block publishing the assets.
250 if ! {
251 if ! {
251 if [[ -n "${highlights//[[:space:]]/}" ]]; then
252 # cliff.toml's tag_pattern skips nightly tags: a nightly lists everything since the last release.
253 if [[ "$TAG" == *-nightly.* ]]; then
254 printf 'Nightly build of main at %s. Not a release.\n\n' "$(git rev-parse --short "$TAG")"
255 "$cliff" --config cliff.toml --unreleased --strip all
256 elif [[ -n "${highlights//[[:space:]]/}" ]]; then
252 printf '## Highlights\n\n%s\n\n<details>\n<summary>All changes</summary>\n\n' "$highlights"
257 printf '## Highlights\n\n%s\n\n<details>\n<summary>All changes</summary>\n\n' "$highlights"
253 "$cliff" --config cliff.toml --current --strip all
258 "$cliff" --config cliff.toml --current --strip all
254 printf '\n</details>\n'
259 printf '\n</details>\n'
.github/workflows/nightly.yml added +32 −0
@@ -0,0 +1,32 @@
1 # Nightly pre-release of main (.github/scripts/nightly.py): tags v<next minor>.0-nightly.<UTC yyyymmddhhmm>
2 # and dispatches build.yml for that tag, which publishes it as a pre-release. Skips a day without commits
3 # and keeps the newest seven nightlies.
4 name: Nightly
5
6 on:
7 schedule:
8 - cron: "23 2 * * *"
9 workflow_dispatch:
10
11 permissions:
12 actions: write
13 contents: write
14
15 concurrency:
16 group: nightly
17 cancel-in-progress: false
18
19 jobs:
20 nightly:
21 runs-on: ubuntu-latest
22 timeout-minutes: 10
23 steps:
24 - uses: actions/checkout@v6
25 with:
26 ref: main
27 fetch-depth: 0
28
29 - name: Tag and build
30 env:
31 GH_TOKEN: ${{ github.token }}
32 run: python3 -I .github/scripts/nightly.py
@@ -0,0 +1,32 @@
1# Nightly pre-release of main (.github/scripts/nightly.py): tags v<next minor>.0-nightly.<UTC yyyymmddhhmm>
2# and dispatches build.yml for that tag, which publishes it as a pre-release. Skips a day without commits
3# and keeps the newest seven nightlies.
4name: Nightly
5
6on:
7 schedule:
8 - cron: "23 2 * * *"
9 workflow_dispatch:
10
11permissions:
12 actions: write
13 contents: write
14
15concurrency:
16 group: nightly
17 cancel-in-progress: false
18
19jobs:
20 nightly:
21 runs-on: ubuntu-latest
22 timeout-minutes: 10
23 steps:
24 - uses: actions/checkout@v6
25 with:
26 ref: main
27 fetch-depth: 0
28
29 - name: Tag and build
30 env:
31 GH_TOKEN: ${{ github.token }}
32 run: python3 -I .github/scripts/nightly.py
README.md +5 −1
@@ -131,7 +131,11 @@ The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
131 131
132 132 ## Quick start
133 133
134 Download the build for your platform from [Releases](https://github.com/danieldaeschle/rusty-teams/releases) and sign in with your work account. Or build it yourself:
134 Download the build for your platform from [Releases](https://github.com/danieldaeschle/rusty-teams/releases) and sign in with your work account.
135
136 Nightly builds of `main` are pre-releases tagged `v<next version>-nightly.<date>`. A nightly updates to newer nightlies and then to the next release; a release build never offers nightlies.
137
138 Or build it yourself:
135 139
136 140 ```bash
137 141 cargo run --release -p app
@@ -131,7 +131,11 @@ The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
131
131
132## Quick start
132## Quick start
133
133
134Download the build for your platform from [Releases](https://github.com/danieldaeschle/rusty-teams/releases) and sign in with your work account. Or build it yourself:
134Download the build for your platform from [Releases](https://github.com/danieldaeschle/rusty-teams/releases) and sign in with your work account.
135
136Nightly builds of `main` are pre-releases tagged `v<next version>-nightly.<date>`. A nightly updates to newer nightlies and then to the next release; a release build never offers nightlies.
137
138Or build it yourself:
135
139
136```bash
140```bash
137cargo run --release -p app
141cargo run --release -p app