From 6510f269f6a4655e69d4d59e012462dca066a65a Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sat, 8 Jul 2023 15:33:09 +0200 Subject: [PATCH] release: add `nixos-*` version branch Best practice for flakes containing NixOS modules. `push-release` now pushes to an extra branch named `nixos-`, alongside branch `release`. This allows users to track a specific NixOS release, so that their config doesn't break when nix-bitcoin switches to a new NixOS release. --- examples/flakes/flake.nix | 2 ++ helper/push-release.sh | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/flakes/flake.nix b/examples/flakes/flake.nix index 4b23845..31216d3 100644 --- a/examples/flakes/flake.nix +++ b/examples/flakes/flake.nix @@ -2,6 +2,8 @@ description = "A basic nix-bitcoin node"; inputs.nix-bitcoin.url = "github:fort-nix/nix-bitcoin/release"; + # You can also use a version branch to track a specific NixOS release + # inputs.nix-bitcoin.url = "github:fort-nix/nix-bitcoin/nixos-23.05"; outputs = { self, nix-bitcoin }: { diff --git a/helper/push-release.sh b/helper/push-release.sh index 56e02e0..38dde9c 100755 --- a/helper/push-release.sh +++ b/helper/push-release.sh @@ -53,6 +53,13 @@ if [[ ! $DRY_RUN ]]; then done fi +nixosVersion=$(sed -nE 's|.*system.stateVersion = "(.*?)".*|\1|p' ../examples/configuration.nix) +if [[ ! $nixosVersion ]]; then + echo "Error fetching NixOS version" + exit 1 +fi +nixosVersionBranch=nixos-$nixosVersion + TMPDIR=$(mktemp -d) if [[ ! $DRY_RUN ]]; then trap 'rm -rf $TMPDIR' EXIT; fi ARCHIVE_NAME=nix-bitcoin-$releaseVersion.tar.gz @@ -74,9 +81,13 @@ gpg -o nar-hash.txt.asc -a --detach-sig nar-hash.txt if [[ $DRY_RUN ]]; then echo "Created v$releaseVersion in $TMPDIR" + echo "NixOS version branch: $nixosVersionBranch" exit 0 fi +#――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― +# Create release + POST_DATA="{ \"tag_name\": \"v$releaseVersion\", \"name\": \"nix-bitcoin-$releaseVersion\", \"body\": \"nix-bitcoin-$releaseVersion\", \"target_comitish\": \"$BRANCH\" }" RESPONSE=$(curl -fsS -H "Authorization: token $OAUTH_TOKEN" -d "$POST_DATA" https://api.github.com/repos/$REPO/releases) ID=$(echo "$RESPONSE" | jq -r '.id') @@ -101,7 +112,8 @@ post_asset "$SHA256SUMS.asc" popd >/dev/null if [[ ! $DRY_RUN ]]; then - git push "$GIT_REMOTE" "${BRANCH}:release" + git push "$GIT_REMOTE" "$BRANCH:release" + git push "$GIT_REMOTE" "$BRANCH:$nixosVersionBranch" fi echo "Successfully created" "$(echo "$POST_DATA" | jq -r .tag_name)"