-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (167 loc) · 7.29 KB
/
build-hds.yaml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Make release
on:
workflow_dispatch:
inputs:
holo-nixpkgs-tag:
description: 'The holo-nixpkgs tag to build from'
required: true
type: string
jobs:
build:
runs-on: 'ubuntu-latest'
outputs:
nixpkgs-revision: ${{ steps.nixpkgs-revision.outputs.nixpkgs-revision }}
build-deps: ${{ steps.build-deps.outputs.build-deps }}
strategy:
matrix:
system:
- x86_64-linux
- aarch64-linux
steps:
- uses: actions/checkout@v4
with:
path: "hds-releases"
- name: "install nix"
uses: "cachix/install-nix-action@v22"
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.holo.host-1:lNXIXtJgS9Iuw4Cu6X0HINLu9sTfcjEntnrgwMQIMcE= cache.holo.host-2:ZJCkX3AUYZ8soxTLfTb60g+F3MkWD7hkH9y8CgqwhDQ=
substituters = https://cache.holo.host https://cache.nixos.org/
- name: "download holo-nixpkgs tag"
run: |
set -eou pipefail
curl -v -L \
--fail-with-body \
-H "Authorization: Bearer ${{ secrets.HOLO_NIXPKGS_READ_KEY }}" \
https://api.github.com/repos/holo-host/holo-nixpkgs/tarball/${{ inputs.holo-nixpkgs-tag }} | \
tar -xz --strip-components=1 --
- name: "build holo-dev-server"
run: |
nix build -L \
--max-jobs 0 \
--out-link holo-dev-server \
'.#legacyPackages.${{ matrix.system }}.holo-dev-server-bin'
- name: get nixpkgs revision
id: nixpkgs-revision
run: |
echo "nixpkgs-revision=$(nix eval --raw '.#legacyPackages.${{ matrix.system }}.holo-dev-server-bin.nixpkgs-revision')" >> ${GITHUB_OUTPUT}
- name: get build deps
id: build-deps
run: |
echo "build-deps=$(nix eval --raw '.#legacyPackages.${{ matrix.system }}.holo-dev-server-bin.propagatedBuildInputs')" >> ${GITHUB_OUTPUT}
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: holo-dev-server-${{ inputs.holo-nixpkgs-tag }}-${{ matrix.system }}
path: |
holo-dev-server
if-no-files-found: error
upload-binary:
runs-on: ubuntu-latest
permissions:
contents: write
needs: build
outputs:
release_name: ${{ steps.date.outputs.date }}
steps:
- name: download x86_64-linux artifact
uses: actions/download-artifact@v4
with:
name: holo-dev-server-${{ inputs.holo-nixpkgs-tag }}-x86_64-linux
path: holo-dev-server
- name: "Create the x86_64-linux tarball"
run: |
chmod +x holo-dev-server/bin/holo-dev-server
tar -czf holo-dev-server-x86_64-linux.tar.gz holo-dev-server
rm -rf holo-dev-server
- name: download aarch64-linux artifact
uses: actions/download-artifact@v4
with:
name: holo-dev-server-${{ inputs.holo-nixpkgs-tag }}-aarch64-linux
path: holo-dev-server
- name: "Create the aarch64-linux tarball"
run: |
chmod +x holo-dev-server/bin/holo-dev-server
tar -czf holo-dev-server-aarch64-linux.tar.gz holo-dev-server
rm -rf holo-dev-server
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d-%H%M%S')" >> ${GITHUB_OUTPUT}
- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
gh release create ${{ steps.date.outputs.date }}
--repo ${{ github.repository }}
--title "Version ${{ steps.date.outputs.date }}"
"holo-dev-server-x86_64-linux.tar.gz"
"holo-dev-server-aarch64-linux.tar.gz"
update-sources:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- build
- upload-binary
steps:
- uses: actions/checkout@v4
- name: "install nix"
uses: "cachix/install-nix-action@v22"
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.holo.host-1:lNXIXtJgS9Iuw4Cu6X0HINLu9sTfcjEntnrgwMQIMcE= cache.holo.host-2:ZJCkX3AUYZ8soxTLfTb60g+F3MkWD7hkH9y8CgqwhDQ=
substituters = https://cache.holo.host https://cache.nixos.org/
- name: prefetch nixpkgs
id: prefetch-nixpkgs
run: |
tar -xzf <(curl --location https://github.com/nixos/nixpkgs/archive/${{ needs.build.outputs.nixpkgs-revision }}.tar.gz)
echo "hash=$(nix hash path --base32 nixpkgs-${{ needs.build.outputs.nixpkgs-revision }}/)" >> ${GITHUB_OUTPUT}
- name: prefetch x86_64-linux binary
id: prefetch-x86_64-linux
run: |
tar -xzf <(curl --location https://github.com/${{ github.repository }}/releases/download/${{ needs.upload-binary.outputs.release_name }}/holo-dev-server-x86_64-linux.tar.gz)
echo "hash=$(nix hash path --base32 holo-dev-server/)" >> ${GITHUB_OUTPUT}
- name: prefetch aarch64-linux binary
id: prefetch-aarch64-linux
run: |
tar -xzf <(curl --location https://github.com/${{ github.repository }}/releases/download/${{ needs.upload-binary.outputs.release_name }}/holo-dev-server-aarch64-linux.tar.gz)
echo "hash=$(nix hash path --base32 holo-dev-server/)" >> ${GITHUB_OUTPUT}
- name: overwrite sources.nix
run: |
cat > sources.nix << EOF
# this file is autogenerated by .github/workflows/build-hds.yml
{
nixpkgs = builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${{ needs.build.outputs.nixpkgs-revision }}.tar.gz";
sha256 = "${{ steps.prefetch-nixpkgs.outputs.hash }}";
};
x86_64-linux.holo-dev-server-bin = builtins.fetchTarball {
url = "https://github.com/${{ github.repository }}/releases/download/${{ needs.upload-binary.outputs.release_name }}/holo-dev-server-x86_64-linux.tar.gz";
sha256 = "${{ steps.prefetch-x86_64-linux.outputs.hash }}";
};
aarch64-linux.holo-dev-server-bin = builtins.fetchTarball {
url = "https://github.com/${{ github.repository }}/releases/download/${{ needs.upload-binary.outputs.release_name }}/holo-dev-server-aarch64-linux.tar.gz";
sha256 = "${{ steps.prefetch-aarch64-linux.outputs.hash }}";
};
}
EOF
- name: overwrite holo-dev-server.deps.json
run: |
cat > holo-dev-server.deps.json << EOF
${{ needs.build.outputs.build-deps }}
EOF
- name: test if flake works
run: |
nix flake show --all-systems
nix flake check -L
- name: commit and push sources.nix
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add sources.nix holo-dev-server.deps.json
git commit -m "update to release ${{ needs.upload-binary.outputs.release_name }}"
git push origin HEAD:refs/heads/main
fi