release: add nixos-* version branch

Best practice for flakes containing NixOS modules.

`push-release` now pushes to an extra branch named `nixos-<version>`,
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.
This commit is contained in:
Erik Arvstedt 2023-07-08 15:33:09 +02:00
parent dd532d4738
commit 6510f269f6
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
2 changed files with 15 additions and 1 deletions

View File

@ -2,6 +2,8 @@
description = "A basic nix-bitcoin node"; description = "A basic nix-bitcoin node";
inputs.nix-bitcoin.url = "github:fort-nix/nix-bitcoin/release"; 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 }: { outputs = { self, nix-bitcoin }: {

View File

@ -53,6 +53,13 @@ if [[ ! $DRY_RUN ]]; then
done done
fi 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) TMPDIR=$(mktemp -d)
if [[ ! $DRY_RUN ]]; then trap 'rm -rf $TMPDIR' EXIT; fi if [[ ! $DRY_RUN ]]; then trap 'rm -rf $TMPDIR' EXIT; fi
ARCHIVE_NAME=nix-bitcoin-$releaseVersion.tar.gz 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 if [[ $DRY_RUN ]]; then
echo "Created v$releaseVersion in $TMPDIR" echo "Created v$releaseVersion in $TMPDIR"
echo "NixOS version branch: $nixosVersionBranch"
exit 0 exit 0
fi fi
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Create release
POST_DATA="{ \"tag_name\": \"v$releaseVersion\", \"name\": \"nix-bitcoin-$releaseVersion\", \"body\": \"nix-bitcoin-$releaseVersion\", \"target_comitish\": \"$BRANCH\" }" 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) RESPONSE=$(curl -fsS -H "Authorization: token $OAUTH_TOKEN" -d "$POST_DATA" https://api.github.com/repos/$REPO/releases)
ID=$(echo "$RESPONSE" | jq -r '.id') ID=$(echo "$RESPONSE" | jq -r '.id')
@ -101,7 +112,8 @@ post_asset "$SHA256SUMS.asc"
popd >/dev/null popd >/dev/null
if [[ ! $DRY_RUN ]]; then if [[ ! $DRY_RUN ]]; then
git push "$GIT_REMOTE" "${BRANCH}:release" git push "$GIT_REMOTE" "$BRANCH:release"
git push "$GIT_REMOTE" "$BRANCH:$nixosVersionBranch"
fi fi
echo "Successfully created" "$(echo "$POST_DATA" | jq -r .tag_name)" echo "Successfully created" "$(echo "$POST_DATA" | jq -r .tag_name)"