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
name: nixpkgs expression for a release
# Fills packaging/nix/package.nix for a release tag — version, source hash,
# cargoHash — builds it as nixpkgs would (from the tag on GitHub) and keeps
# the result as an artifact, ready for the nixpkgs PR (RELEASE.md).
on:
workflow_dispatch:
inputs:
tag:
description: Release tag, e.g. 18.2.0
required: true
jobs:
package:
runs-on: ubuntu-latest
env:
TAG: ${{ inputs.tag }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31.11.1
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Fill in and build
run: |
f=packaging/nix/package.nix
sed -i "s/^ version = \".*\";/ version = \"$TAG\";/" "$f"
raw=$(nix-prefetch-url --unpack "https://github.com/bohdaq/rust-web-server/archive/refs/tags/$TAG.tar.gz" 2>/dev/null)
src=$(nix hash convert --hash-algo sha256 --to sri "$raw")
sed -i "0,/hash = lib.fakeHash;/s||hash = \"$src\";|" "$f"
# The fake cargoHash makes the vendor step fail with the real one.
cargo=$(nix-build packaging/nix/release.nix 2>&1 | awk '/got:/ {print $2; exit}')
test -n "$cargo"
sed -i "s|cargoHash = lib.fakeHash;|cargoHash = \"$cargo\";|" "$f"
nix-build packaging/nix/release.nix
./result/bin/rws --version
cat "$f"
- uses: actions/upload-artifact@v4
with:
name: package.nix
path: packaging/nix/package.nix