Skip to content

Commit

Permalink
various improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Jun 5, 2024
1 parent b2126d3 commit f8d0dbe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ jobs:
git commit -am "docs: release ${{ needs.process-inputs.outputs.MAJOR_MINOR }}"
# Clean up auxiliary files, so next steps run on a clean tree
git clean -fx :/
- name: Update versions.json
- name: Download updated contrast releases file (from release branch)
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e #v4.1.7
with:
name: versions-json
path: ./contrast-main/packages/versions.json
- name: Commit versions.json
name: contrast-releases.json
path: ./contrast-main/packages/contrast-releases.json
- name: Commit updated contrast-releases.json
working-directory: contrast-main
run: |
git add ./packages/versions.json
git commit -m "ci: update versions.json with ${{ needs.process-inputs.outputs.MAJOR_MINOR_PATCH }}"
git add ./packages/contrast-releases.json
git commit -m "packages/contrast-releases: add ${{ needs.process-inputs.outputs.MAJOR_MINOR_PATCH }}"
- name: Bump flake version to post release patch pre-version
if: ${{ inputs.kind == 'minor' }}
id: bump
Expand Down Expand Up @@ -262,15 +262,15 @@ jobs:
- name: Build CLI
run: |
nix build -L .#cli-release
- name: Update versions.json in main
- name: Update contrast-releases.json with new release
env:
VERSION: ${{ needs.process-inputs.outputs.MAJOR_MINOR_PATCH }}
run: nix run ".#scripts.update-versions-json"
- name: Upload versions.json
run: nix run .#scripts.update-contrast-releases
- name: Upload updated contrast-releases.json (for main branch PR)
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: versions-json
path: ./packages/versions.json
name: contrast-releases.json
path: ./packages/contrast-releases.json
- name: Clean up git tree
run: git clean -fx :/
- name: Create draft release
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@
'';
};

update-versions-json = writeShellApplication {
name = "update-versions-json";
update-contrast-releases = writeShellApplication {
name = "update-contrast-releases";
runtimeInputs = with pkgs; [
jq
];
text = builtins.readFile ./update-versions-json.sh;
text = builtins.readFile ./update-contrast-releases.sh;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

set -euo pipefail

readonly versionsFile="./packages/contrast-releases.json"

# check if the version environment variable is set
if [[ -z "${VERSION:-}" ]]; then
echo "[x] VERSION environment variable not set"
if [[ -z ${VERSION:-} ]]; then
echo "[x] Error: VERSION environment variable not set" >&2
exit 1
fi

Expand All @@ -24,33 +26,33 @@ for field in "${!fields[@]}"; do
jq --arg NAME "$field" \
--arg VERSION "$VERSION" \
'.[$NAME] | map(select(.version == $VERSION))' \
./packages/versions.json
"${versionsFile}"
)
if [[ ! "$out" = "[]" ]]; then
echo "[x] Version $VERSION exists for entry $field"
if [[ $out != "[]" ]]; then
echo "[x] Error: version $VERSION exists for entry $field" >&2
exit 1
fi

# get the file path
file=${fields["$field"]}

echo "[*] Creating hash for $file"
echo "[*] Creating hash for $file" >&2
hash=$(nix hash file --sri --type sha256 "$(realpath "$file")")
echo " $hash"
echo " $hash" >&2

echo "[*] Updating ./packages/versions.json for $field"
echo "[*] Updating ${versionsFile} for $field" >&2
out=$(
jq --arg NAME "$field" \
--arg HASH "$hash" \
--arg VERSION "$VERSION" \
'.[$NAME] |= . + [{"version": $VERSION,hash: $HASH}]' \
./packages/versions.json
"${versionsFile}"
)
echo "$out" >./packages/versions.json
echo "$out" >"${versionsFile}"

echo ""
done

echo "[*] Formatting ./packages/versions.json"
out=$(jq --indent 2 . ./packages/versions.json)
echo "$out" >./packages/versions.json
echo "[*] Formatting ${versionsFile}"
out=$(jq --indent 2 . "${versionsFile}")
echo "$out" >"${versionsFile}"

0 comments on commit f8d0dbe

Please sign in to comment.