nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
3
4# shellcheck shell=bash
5
6if [ -n "$GITHUB_TOKEN" ]; then
7 TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
8fi
9
10if [[ $# -gt 1 || $1 == -* ]]; then
11 echo "Regenerates packaging data for the woodpecker packages."
12 echo "Usage: $0 [git release tag]"
13 exit 1
14fi
15
16set -x
17
18cd "$(dirname "$0")"
19version="$1"
20
21set -euo pipefail
22
23if [ -z "$version" ]; then
24 version="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/woodpecker-ci/woodpecker/releases?per_page=1" | jq -r '.[0].tag_name')"
25fi
26
27# strip leading "v"
28version="${version#v}"
29
30# Woodpecker repository
31src_hash=$(nix-prefetch-github woodpecker-ci woodpecker --rev "v${version}" | jq -r .sha256)
32
33# Front-end dependencies
34woodpecker_src="https://raw.githubusercontent.com/woodpecker-ci/woodpecker/v$version"
35wget "${TOKEN_ARGS[@]}" "$woodpecker_src/web/package.json" -O woodpecker-package.json
36
37web_tmpdir=$(mktemp -d)
38trap 'rm -rf "$web_tmpdir"' EXIT
39pushd "$web_tmpdir"
40wget "${TOKEN_ARGS[@]}" "$woodpecker_src/web/yarn.lock"
41yarn_hash=$(prefetch-yarn-deps yarn.lock)
42popd
43
44# Use friendlier hashes
45src_hash=$(nix hash to-sri --type sha256 "$src_hash")
46yarn_hash=$(nix hash to-sri --type sha256 "$yarn_hash")
47
48sed -i -E -e "s#version = \".*\"#version = \"$version\"#" common.nix
49sed -i -E -e "s#srcSha256 = \".*\"#srcSha256 = \"$src_hash\"#" common.nix
50sed -i -E -e "s#yarnSha256 = \".*\"#yarnSha256 = \"$yarn_hash\"#" common.nix