summaryrefslogtreecommitdiffstats
path: root/scripts/release.sh
blob: beb9594b84c7eb16be80d2ae71060f79a21c8129 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash

set -euo pipefail

git checkout master
git pull

version=$(jq -r .release version.json)

# branch off ${version}
echo "Cutting nix-darwin-${version} release branch"

git checkout -b "nix-darwin-${version}"

sed -i -e "s!- master!- nix-darwin-${version}!" .github/workflows/test.yml
sed -i -e "s!NIXPKGS_BRANCH: nixpkgs-unstable!NIXPKGS_BRANCH: nixpkgs-${version}-darwin!" .github/workflows/test.yml

sed -i -e "s!nixpkgs-unstable!nixpkgs-${version}-darwin!" modules/examples/flake/flake.nix
sed -i -e "s!github:nix-darwin/nix-darwin/master!github:nix-darwin/nix-darwin/nix-darwin-${version}!" modules/examples/flake/flake.nix

sed -i -e "s!nixpkgs/unstable!nixpkgs/stable!g" modules/nix/nixpkgs.nix

sed -i -e "s!nixpkgs-unstable!nixpkgs-${version}-darwin!" flake.nix
nix flake lock

cat <<EOF > README.md
# nix-darwin

This is the ${version} release branch of nix-darwin. See [the main readme](https://github.com/nix-darwin/nix-darwin#readme) for documentation
EOF

cat <<EOF > version.json
{
  "release": "${version}",
  "isReleaseBranch": true
}
EOF

git add .
git commit -m "version: branch off ${version}"

# update master
echo "Updating master to point to next version"

git checkout master

## update version.json to point to the next version

IFS='.' read -r major minor <<< "$version"

if [[ "$minor" = "11" ]]; then
    major=$(( major + 1 ))
    minor="05"
else
    minor="11"
fi

cat <<EOF > version.json
{
  "release": "${major}.${minor}",
  "isReleaseBranch": false
}
EOF

## update readme so that instructions refer to the version we're cutting (our supported stable version)

sed -i -e "s![0-9][0-9]\.[0-9][0-9]!${version}!g" README.md

git add .
git commit -m "version: bump to ${major}.${minor}"

nix flake update

git add .
git commit -m "flake.lock: update"