Skip to content

Commit 8ad3376

Browse files
basvandijkmergify[bot]
authored andcommitted
Add a jobset for doing SDK releases (#164)
ci/release.nix is called by the sdk-release jobset on hydra. It calls release-jobset.nix which returns the dfx-release and install-sh-release derivations but only when the git revision has been tagged with a release tag (v0.1.2). In that case the version in those derivations is set to the version in the tag ensuring that they get rebuild.
1 parent da99215 commit 8ad3376

File tree

5 files changed

+52
-8
lines changed

5 files changed

+52
-8
lines changed

ci/release.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
2+
, scrubJobs ? true
3+
, src ? null
4+
}:
5+
(import ../nix {}).ci ../release-jobset.nix { inherit supportedSystems scrubJobs src; }

jobset.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
, crossSystem ? null
33
, config ? {}
44
, overlays ? []
5+
, src ? null
56
}: {
67
inherit (import ./nix { inherit system crossSystem config overlays; }) dfinity-sdk;
78
}

nix/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
, crossSystem ? null
55
, config ? {}
66
, overlays ? []
7+
, releaseVersion ? "latest"
78
}:
89
let
910
# The `common` repo provides code (mostly Nix) that is used in the
@@ -20,9 +21,9 @@ let
2021
else builtins.fetchGit {
2122
name = "common-sources";
2223
url = "ssh://[email protected]/dfinity-lab/common";
23-
rev = "d5af3fda55af07de25f06fc46a2bf5f83424f02b";
24+
rev = "bbf39c31e08b4ab7db82f799a3e3c693a0fdced6";
2425
};
2526
in import commonSrc {
2627
inherit system crossSystem config;
27-
overlays = import ./overlays ++ overlays;
28+
overlays = import ./overlays ++ [ (_self: _super: { inherit releaseVersion; }) ] ++ overlays;
2829
}

nix/overlays/dfinity-sdk.nix

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,15 @@ in {
2929
public-folder = super.callPackage ../public.nix {};
3030
};
3131

32-
dfx-release = mkRelease "dfx"
33-
# This is not the tagged version, but something afterwards
34-
"latest" # once INF-495 is in, we will use: packages.rust-workspace.version
35-
packages.rust-workspace-standalone
36-
"dfx";
32+
dfx-release = mkRelease "dfx" self.releaseVersion packages.rust-workspace-standalone "dfx";
3733

3834
# The following prepares a manifest for copying install.sh
3935
# The release part also checks if the install.sh script is well formatted and has no shellcheck issues.
4036
# We ignore 'local' warning by shellcheck, because any existing sh implementation supports it.
4137
# TODO: streamline mkRelease and this
4238
install-sh-release =
4339
let
44-
version = "latest";
40+
version = self.releaseVersion;
4541
shfmtOpts = "-p -i 4 -ci -bn -s";
4642
shellcheckOpts = "-s sh -S warning";
4743
# We want to include the last revision of the install script into

release-jobset.nix

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{ system ? builtins.currentSystem
2+
, crossSystem ? null
3+
, config ? {}
4+
, overlays ? []
5+
6+
# Hydra will pass an argument to this jobset expression for every
7+
# input of the jobset. In our case we only have a single `src` input
8+
# representing the git checkout of the SDK repo:
9+
#
10+
# https://hydra.dfinity.systems/jobset/dfinity-ci-build/sdk#tabs-configuration
11+
#
12+
# This `src` argument contains information about the input for example:
13+
#
14+
# { outPath = builtins.storePath /nix/store/ma2dfyfyxdi6idbza6dyp34zhxh12nmm-source;
15+
# inputType = "git";
16+
# uri = "[email protected]:dfinity-lab/sdk.git";
17+
# rev = "8882d8c97decbb3c33923ca9e8ab785621a61207";
18+
# revCount = 2514;
19+
# gitTag = "8882d8c9"; # This defaults to the rev when there's no git tag.
20+
# shortRev = "8882d8c9";
21+
# }
22+
#
23+
# See: https://github.com/NixOS/hydra/blob/037f6488f633dbf15ca2d93a0c117f6738c707fe/src/lib/Hydra/Plugin/GitInput.pm#L241:L248
24+
#
25+
# We're primarily interested in the `src.gitTag` since that should trigger a release.
26+
, src ? null
27+
}:
28+
let
29+
# doRelease is true when the git tag is of the right release format like `0.1.2`.
30+
doRelease = src != null && versionMatches != null;
31+
32+
# versionMatch is `null` if `src.gitTag` is not of the right format like "1.23.456"
33+
# and it's a list of matches like [ "1.23.456" ] when it is.
34+
versionMatches = builtins.match "([0-9]+\.[0-9]+\.[0-9]+)" src.gitTag;
35+
releaseVersion = if versionMatches == null then "latest" else builtins.head versionMatches;
36+
37+
pkgs = import ./nix { inherit system config overlays releaseVersion; };
38+
39+
in pkgs.lib.optionalAttrs doRelease {
40+
inherit (pkgs.dfinity-sdk) dfx-release install-sh-release;
41+
}

0 commit comments

Comments
 (0)