git.iko.soy/rowtype-yoga/package-sets
on master help sign in
Add latest-compatible-sets.json file (#702)

This file is automatically updated when new releases are created using the new update-latest-compatible-sets.sh script.

commit765863b1de5212bd26a176e597299b68f963ee1b authorHarry Garrood <harry@garrood.me> dateFri 18 Sep 2020, 14:39 (6 years ago) parent5012c2e
3 files changed+69
.github/workflows/release.yml+12 latest-compatible-sets.json+15 update-latest-compatible-sets.sh+42
.github/workflows/release.yml+12
@@ -34,3 +34,15 @@ jobs:
3434 asset_path: ./packages.dhall
3535 asset_name: packages.dhall
3636 asset_content_type: application/x-dhall
37+ # Now checkout master in order to update the latest-compatible-sets.json file
38+ - uses: actions/checkout@v2
39+ with:
40+ ref: 'master'
41+ - name: Update latest-compatible-sets.json
42+ run: |
43+ nix-shell --run './update-latest-compatible-sets.sh ${{ github.ref }}'
44+ - name: Commit changes to latest-compatible-sets.json
45+ uses: stefanzweifel/git-auto-commit-action@v4
46+ with:
47+ commit_message: Update latest-compatible-sets.json for ${{ github.ref }}
48+ file_pattern: latest-compatible-sets.json
latest-compatible-sets.jsonnew file+15
@@ -0,0 +1,15 @@
1+{
2+ "0.12.0": "psc-0.12.0-20181024",
3+ "0.12.1": "psc-0.12.1-20190107",
4+ "0.12.2": "psc-0.12.2-20190210",
5+ "0.12.3": "psc-0.12.3-20190409",
6+ "0.12.4": "psc-0.12.4-20190418",
7+ "0.12.5": "psc-0.12.5-20190525",
8+ "0.13.0": "psc-0.13.0-20190713",
9+ "0.13.2": "psc-0.13.2-20190815",
10+ "0.13.3": "psc-0.13.3-20191005",
11+ "0.13.4": "psc-0.13.4-20191125",
12+ "0.13.5": "psc-0.13.5-20200103",
13+ "0.13.6": "psc-0.13.6-20200507",
14+ "0.13.8": "psc-0.13.8-20200911-2"
15+}
update-latest-compatible-sets.shnew file+42
@@ -0,0 +1,42 @@
1+#!/usr/bin/env nix-shell
2+#!nix-shell -i bash
3+
4+set -euo pipefail
5+
6+# This script takes one command-line argument of a package set tag which is
7+# about to be released, and updates the latest-compatible-sets.json file where
8+# necessary so that the new package set is marked as the latest compatible set
9+# for the appropriate compiler version.
10+
11+if [ $# -ne 1 ]; then
12+ echo >&2 "Expected one argument, got $#"
13+ echo >&2 "Usage: update-latest-compatible-sets.sh PACKAGE_SET_VERSION"
14+ exit 1
15+fi
16+
17+function get_inputs() {
18+ # Get the existing mapping of compiler versions to latest package sets for
19+ # that version
20+ cat latest-compatible-sets.json
21+ # Print a JSON object in the same schema as the latest-compatible-sets.json
22+ # file, containing just the version which is about to be released. e.g.
23+ # { "0.13.8": "psc-0.13.8-20200911-2" }
24+ echo $1 | jq --raw-input '{ (split("-")[1]): .}'
25+}
26+
27+function combine() {
28+ # Change the input JSON object into an array of objects like
29+ #
30+ # { key: "0.13.8", value: "psc-0.13.8-20200911-2" }
31+ #
32+ # then sort by 'value' so that more recent releases come later, and finally
33+ # convert back to a JSON object. The sorting is important so that newer
34+ # releases for a given compiler version that they take precedence when we
35+ # combine the array back into a single object.
36+ jq --slurp 'map(to_entries | .[]) | sort_by(.value) | from_entries'
37+}
38+
39+tag=${1#refs/tags/}
40+echo >&2 "Updating latest-compatible-sets.json for $tag"
41+get_inputs $tag | combine > latest-compatible-sets.json.tmp
42+mv latest-compatible-sets.json.tmp latest-compatible-sets.json