workflow: use attic

This commit is contained in:
cy 2025-03-13 13:43:35 -04:00
parent f4c7243b69
commit 25c7eb865a
Signed by: cy
SSH key fingerprint: SHA256:o/geVWV4om1QhUSkKvDQeW/eAihwnjyXkqMwrVdbuts
2 changed files with 98 additions and 25 deletions

View file

@ -6,6 +6,17 @@ on:
description: "package to build"
required: false
type: string
env:
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
NIX_CONFIG: |
show-trace = true
extra-substituters = https://cache.cy7.sh/main
extra-trusted-public-keys = main:Ku31HoEWcBtfggge2VGj+QTkVrQuIwRIMGyfV/5VQP0=
experimental-features = nix-command flakes
extra-experimental-features = nix-command flakes
accept-flake-config = true
TERM: ansi
jobs:
build-packages:
strategy:
@ -18,6 +29,7 @@ jobs:
- ubuntu-24.04-arm
- macos-latest
- macos-13
runs-on: ${{ matrix.os }}
steps:
- name: Install Nix
@ -27,12 +39,26 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: cachix/cachix-action@v14
with:
name: cything
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
useDaemon: false
installCommand: nix profile install nixpkgs#cachix
- name: setup attic
run: |
nix profile install github:zhaofengli/attic
attic login cy7 https://cache.cy7.sh "$ATTIC_TOKEN"
- run: nix build -L ${{ matrix.package }}
- name: cache result
run: |
derivation="$(nix path-info --derivation "${{ matrix.package }}")"
cache="$(nix-store --query --requisites --include-outputs "$derivation")"
attic push main --stdin <<< "$cache"
- name: prepare tarball to upload
run: nix run github:nixos/nixpkgs#gnutar hcvf result.tar result
- name: upload result
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: result.tar
if-no-files-found: error