From ee29c3411385236a197739966fceb7b2d72b6f7c Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sat, 28 Oct 2023 19:48:09 -0700 Subject: [PATCH] Check in recent flake work --- flake.nix | 33 ++++++++++++++++++++++++--------- upload_to_github.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 9 deletions(-) create mode 100755 upload_to_github.sh diff --git a/flake.nix b/flake.nix index 2c8c5d7..13cef1b 100644 --- a/flake.nix +++ b/flake.nix @@ -43,7 +43,20 @@ exeAttr = "haskell-notebook-language-server:exe:haskell-notebook-language-server"; - allVersions = with pkgs.lib; ( + packageForGitHub = hnls: ghcName: pkgs.runCommand "haskell-notebook-language-server-${hnls.version}" { nativeBuildInputs = [pkgs.binutils]; } '' + name="haskell-notebook-language-server-${hnls.version}-${ghcName}-x86_64-linux" + + mkdir -p $out + cp ${hnls}/bin/haskell-notebook-language-server $out/$name + + cd $out + chmod u+w "$name" + strip "$name" + + tar -czvf $name.tar.gz $name + ''; + + allVersions = with pkgs.lib; listToAttrs ( concatMap (info: [ (nameValuePair info.name (flake info.name (srcWithStackYaml info.stackYaml)).packages.${exeAttr}) (nameValuePair "${info.name}-static" (flakeStatic info.name (srcWithStackYaml info.stackYaml)).packages.${exeAttr}) @@ -51,7 +64,7 @@ { name = "ghc8107"; stackYaml = "stack-8.10.7.yaml"; } { name = "ghc902"; stackYaml = "stack-9.0.2.yaml"; } { name = "ghc928"; stackYaml = "stack-9.2.8.yaml"; } - { name = "ghc945"; stackYaml = "stack-9.4.5.yaml"; } + # { name = "ghc947"; stackYaml = "stack-9.4.7.yaml"; } # { name = "ghc962"; stackYaml = "stack-9.6.2.yaml"; } ] ); @@ -62,13 +75,15 @@ inherit (pkgs) cabal2nix; # inherit lsp-types; - all = with pkgs.lib; pkgs.linkFarm "haskell-notebook-language-server-all" ( - map (x: { - inherit (x) name; - path = x.value; - }) allVersions - ); - } // pkgs.lib.listToAttrs allVersions; + inherit allVersions; + staticVersions = pkgs.lib.filterAttrs (n: v: pkgs.lib.hasSuffix "-static" n) allVersions; + all = pkgs.linkFarm "haskell-notebook-language-server-all" allVersions; + + githubArtifacts = with pkgs; symlinkJoin { + name = "haskell-notebook-language-server-artifacts"; + paths = lib.mapAttrsToList (n: v: packageForGitHub v (lib.removeSuffix "-static" n)) staticVersions; + }; + } // allVersions; inherit flake; diff --git a/upload_to_github.sh b/upload_to_github.sh new file mode 100755 index 0000000..aade8cc --- /dev/null +++ b/upload_to_github.sh @@ -0,0 +1,35 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p jq github-cli + +set -e + +BUILT=$(nix build .#githubArtifacts --no-link --json | jq -r '.[0].outputs.out') +echo "Built: $BUILT" +ls "$BUILT" + +VERSION="$(nix eval .#ghc928-static.version --raw)" + +IFS=$'\n' +ARTIFACTS=$(find "$BUILT" -name "*.tar.gz") +unset IFS +echo "Saw artifacts: $ARTIFACTS" + +# Smoke check +# FIRST_EXECUTABLE=$(find "$BUILT" -type f -executable | head -n 1) +# echo "FIRST_EXECUTABLE: $FIRST_EXECUTABLE" +# $FIRST_EXECUTABLE --help > /dev/null 2>&1 + +TAG=v"$VERSION" +echo "Tagging at $TAG" +git tag "$TAG" -f +echo "" + +echo "Pushing tags" +git push --tags +echo "" + +echo "Creating release $TAG" +gh release create "$TAG" \ + ${ARTIFACTS[@]} \ + --title "$TAG" \ + --notes ""