Skip to content

Commit e91a3cb

Browse files
committed
cache nix builds in CI to cachix
1 parent abfe4c9 commit e91a3cb

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/master.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
release:
1010
name: 'Publish Release'
1111
runs-on: [self-hosted, linux, flyweight]
12+
needs: [cachix-release, cachix-release-dependencies]
1213
steps:
1314
- name: 'Check out code'
1415
uses: actions/checkout@v4
@@ -22,3 +23,93 @@ jobs:
2223
set -x
2324
VERSION=v$(cat package/version)
2425
gh release create ${VERSION} --target ${{ github.sha }}
26+
27+
cachix-release:
28+
name: 'k-framework-binary cachix release'
29+
strategy:
30+
matrix:
31+
include:
32+
- runner: ubuntu-24.04
33+
os: ubuntu-24.04
34+
- runner: self-macos-latest
35+
os: self-macos-latest
36+
runs-on: ${{ matrix.runner }}
37+
timeout-minutes: 120
38+
steps:
39+
- name: 'Check out code'
40+
uses: actions/checkout@v4
41+
with:
42+
ref: ${{ github.event.push.head.sha }}
43+
fetch-depth: 0
44+
- name: 'Install Nix'
45+
if: ${{ !startsWith(matrix.os, 'self') }}
46+
uses: cachix/install-nix-action@v31.5.1
47+
with:
48+
install_url: https://releases.nixos.org/nix/nix-2.30.1/install
49+
extra_nix_config: |
50+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
51+
substituters = http://cache.nixos.org
52+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
53+
- name: 'Install Cachix'
54+
if: ${{ !startsWith(matrix.os, 'self') }}
55+
uses: cachix/cachix-action@v16
56+
with:
57+
name: k-framework-binary
58+
- name: 'Publish skribe to k-framework-binary cache'
59+
uses: workflow/nix-shell-action@v3.4.0
60+
env:
61+
GC_DONT_GC: 1
62+
CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_PUBLIC_TOKEN }}'
63+
with:
64+
packages: jq
65+
script: |
66+
export PATH="$(nix build github:runtimeverification/kup --no-link --json | jq -r '.[].outputs | to_entries[].value')/bin:$PATH"
67+
kup publish --verbose k-framework-binary .#skribe --keep-days 180
68+
kup publish --verbose k-framework-binary .#skribe.rust --keep-days 180
69+
70+
cachix-release-dependencies:
71+
name: 'k-framework cachix release'
72+
strategy:
73+
matrix:
74+
include:
75+
- runner: ubuntu-24.04
76+
os: ubuntu-24.04
77+
- runner: self-macos-latest
78+
os: self-macos-latest
79+
runs-on: ${{ matrix.runner }}
80+
timeout-minutes: 120
81+
steps:
82+
- name: 'Check out code'
83+
uses: actions/checkout@v4
84+
with:
85+
ref: ${{ github.event.push.head.sha }}
86+
fetch-depth: 0
87+
- name: 'Install Nix'
88+
if: ${{ !startsWith(matrix.os, 'self') }}
89+
uses: cachix/install-nix-action@v31.5.1
90+
with:
91+
install_url: https://releases.nixos.org/nix/nix-2.30.1/install
92+
extra_nix_config: |
93+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
94+
substituters = http://cache.nixos.org
95+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
96+
- name: 'Install Cachix'
97+
if: ${{ !startsWith(matrix.os, 'self') }}
98+
uses: cachix/cachix-action@v16
99+
with:
100+
name: k-framework-binary
101+
- name: 'Build and cache skribe and skribe dependencies'
102+
uses: workflow/nix-shell-action@v3
103+
env:
104+
GC_DONT_GC: 1
105+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_PUBLIC_TOKEN }}
106+
with:
107+
packages: jq
108+
script: |
109+
SKRIBE=$(nix build --extra-experimental-features 'nix-command flakes' .#skribe --json | jq -r '.[].outputs | to_entries[].value')
110+
DRV_SKRIBE=$(nix-store --query --deriver ${SKRIBE})
111+
nix-store --query --requisites --include-outputs ${DRV_SKRIBE} | cachix push k-framework
112+
113+
SKRIBE_RUST=$(nix build --extra-experimental-features 'nix-command flakes' .#skribe.rust --json | jq -r '.[].outputs | to_entries[].value')
114+
DRV_SKRIBE_RUST=$(nix-store --query --deriver ${SKRIBE_RUST})
115+
nix-store --query --requisites --include-outputs ${DRV_SKRIBE_RUST} | cachix push k-framework

0 commit comments

Comments
 (0)