releng: move officialRelease to version.json

This was causing a few bits of suffering downstream, in particular, in
the NixOS module, which, after this change, can have the
`officialRelease` stuff in *it* completely deleted since we now have
correct defaulting in package.nix for it.

It also eliminates some automated editing of Nix files, which is
certainly always welcome to eliminate.

Fixes: lix-project/lix#406
Change-Id: Id12f3018cff4633e379dbfcbe26b7bc84922bdaf
This commit is contained in:
jade 2024-07-23 23:25:18 +02:00
parent b5c6ce7a53
commit 5eecdd3ae9
6 changed files with 22 additions and 15 deletions

View file

@ -59,7 +59,8 @@
(Run `touch .nocontribmsg` to hide this message.) (Run `touch .nocontribmsg` to hide this message.)
''; '';
officialRelease = false; versionJson = builtins.fromJSON (builtins.readFile ./version.json);
officialRelease = versionJson.official_release;
# Set to true to build the release notes for the next release. # Set to true to build the release notes for the next release.
buildUnreleasedNotes = true; buildUnreleasedNotes = true;
@ -419,7 +420,7 @@
pkgs: stdenv: pkgs: stdenv:
let let
nix = pkgs.callPackage ./package.nix { nix = pkgs.callPackage ./package.nix {
inherit stdenv officialRelease versionSuffix; inherit stdenv versionSuffix;
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox; busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox;
internalApiDocs = false; internalApiDocs = false;
}; };

View file

@ -52,7 +52,7 @@
pname ? "lix", pname ? "lix",
versionSuffix ? "", versionSuffix ? "",
officialRelease ? false, officialRelease ? __forDefaults.versionJson.official_release,
# Set to true to build the release notes for the next release. # Set to true to build the release notes for the next release.
buildUnreleasedNotes ? true, buildUnreleasedNotes ? true,
internalApiDocs ? false, internalApiDocs ? false,
@ -68,6 +68,8 @@
__forDefaults ? { __forDefaults ? {
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform; canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
versionJson = builtins.fromJSON (builtins.readFile ./version.json);
boehmgc-nix = boehmgc.override { enableLargeConfig = true; }; boehmgc-nix = boehmgc.override { enableLargeConfig = true; };
editline-lix = editline.overrideAttrs (prev: { editline-lix = editline.overrideAttrs (prev: {
@ -83,8 +85,7 @@ let
inherit (lib) fileset; inherit (lib) fileset;
inherit (stdenv) hostPlatform buildPlatform; inherit (stdenv) hostPlatform buildPlatform;
versionJson = builtins.fromJSON (builtins.readFile ./version.json); version = __forDefaults.versionJson.version + versionSuffix;
version = versionJson.version + versionSuffix;
aws-sdk-cpp-nix = aws-sdk-cpp.override { aws-sdk-cpp-nix = aws-sdk-cpp.override {
apis = [ apis = [
@ -381,8 +382,6 @@ stdenv.mkDerivation (finalAttrs: {
pegtl pegtl
; ;
inherit officialRelease;
# The collection of dependency logic for this derivation is complicated enough that # The collection of dependency logic for this derivation is complicated enough that
# it's easier to parameterize the devShell off an already called package.nix. # it's easier to parameterize the devShell off an already called package.nix.
mkDevShell = mkDevShell =

View file

@ -30,7 +30,7 @@ First, we prepare the release. `python -m releng prepare` is used for this.
Then we tag the release with `python -m releng tag`: Then we tag the release with `python -m releng tag`:
* Git HEAD is detached. * Git HEAD is detached.
* `officialRelease = true` is set in `flake.nix`, this is committed, and a * `"official_release": true` is set in `version.json`, this is committed, and a
release is tagged. release is tagged.
* The tag is merged back into the last branch (either `main` for new releases * The tag is merged back into the last branch (either `main` for new releases
or `release-MAJOR` for maintenance releases) with `git merge -s ours VERSION` or `release-MAJOR` for maintenance releases) with `git merge -s ours VERSION`

View file

@ -11,7 +11,7 @@ from . import environment
from .environment import RelengEnvironment from .environment import RelengEnvironment
from . import keys from . import keys
from . import docker from . import docker
from .version import VERSION, RELEASE_NAME, MAJOR from .version import VERSION, RELEASE_NAME, MAJOR, OFFICIAL_RELEASE
from .gitutils import verify_are_on_tag, git_preconditions from .gitutils import verify_are_on_tag, git_preconditions
from . import release_notes from . import release_notes
@ -39,12 +39,18 @@ def setup_creds(env: RelengEnvironment):
def official_release_commit_tag(force_tag=False): def official_release_commit_tag(force_tag=False):
print('[+] Setting officialRelease in flake.nix and tagging') print('[+] Setting officialRelease in version.json and tagging')
prev_branch = $(git symbolic-ref --short HEAD).strip() prev_branch = $(git symbolic-ref --short HEAD).strip()
git switch --detach git switch --detach
sed -i 's/officialRelease = false/officialRelease = true/' flake.nix
git add flake.nix # Must be done in two parts due to buffering (opening the file immediately
# would truncate it).
new_version_json = $(jq --indent 4 '.official_release = true' version.json)
with open('version.json', 'w') as fh:
fh.write(new_version_json)
git add version.json
message = f'release: {VERSION} "{RELEASE_NAME}"\n\nRelease produced with releng/create_release.xsh' message = f'release: {VERSION} "{RELEASE_NAME}"\n\nRelease produced with releng/create_release.xsh'
git commit -m @(message) git commit -m @(message)
git tag @(['-f'] if force_tag else []) -a -m @(message) @(VERSION) git tag @(['-f'] if force_tag else []) -a -m @(message) @(VERSION)
@ -250,15 +256,14 @@ def build_manual(eval_result):
def upload_manual(env: RelengEnvironment): def upload_manual(env: RelengEnvironment):
stable = json.loads($(nix eval --json '.#nix.officialRelease')) if OFFICIAL_RELEASE:
if stable:
version = MAJOR version = MAJOR
else: else:
version = 'nightly' version = 'nightly'
print('[+] aws s3 sync manual') print('[+] aws s3 sync manual')
aws s3 sync @(MANUAL)/ @(env.docs_bucket)/manual/lix/@(version)/ aws s3 sync @(MANUAL)/ @(env.docs_bucket)/manual/lix/@(version)/
if stable: if OFFICIAL_RELEASE:
aws s3 sync @(MANUAL)/ @(env.docs_bucket)/manual/lix/stable/ aws s3 sync @(MANUAL)/ @(env.docs_bucket)/manual/lix/stable/

View file

@ -4,3 +4,4 @@ version_json = json.load(open('version.json'))
VERSION = version_json['version'] VERSION = version_json['version']
MAJOR = '.'.join(VERSION.split('.')[:2]) MAJOR = '.'.join(VERSION.split('.')[:2])
RELEASE_NAME = version_json['release_name'] RELEASE_NAME = version_json['release_name']
OFFICIAL_RELEASE = version_json['official_release']

View file

@ -1,4 +1,5 @@
{ {
"version": "2.91.0-dev", "version": "2.91.0-dev",
"official_release": false,
"release_name": "TBA" "release_name": "TBA"
} }