Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OMICRON_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6deb5ffe34c4227f516a882ee8781153cd12d6c2
a14e6bb877451f7307ced4b079c298855cb974dc
9 changes: 5 additions & 4 deletions app/api/__generated__/Api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/api/__generated__/OMICRON_VERSION

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"fmt:check": "oxfmt --check",
"openapi-gen-ts": "openapi-gen-ts",
"gen-api": "./tools/generate_api_client.sh",
"gen-api-latest": "./tools/gen_api_latest.sh",
"postinstall": "patch-package",
"prepare": "husky"
},
Expand Down
33 changes: 33 additions & 0 deletions tools/gen_api_latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
#
# Copyright Oxide Computer Company

# Like `npm run gen-api`, but first pins OMICRON_VERSION to the latest omicron
# main commit (or the commit at an optional ref passed as the first argument).
# See docs/update-pinned-api.md.

set -o errexit
set -o pipefail

REF="${1:-main}"

OLD_SHA=$(head -n 1 OMICRON_VERSION)
NEW_SHA=$(curl --fail --silent --show-error \
"https://api.github.com/repos/oxidecomputer/omicron/commits/$REF" | jq -r '.sha')

if [[ ! "$NEW_SHA" =~ ^[0-9a-f]{40}$ ]]; then
echo "Could not resolve omicron ref '$REF' to a commit hash" >&2
exit 1
fi

if [[ "$NEW_SHA" == "$OLD_SHA" ]]; then
echo "OMICRON_VERSION already at $NEW_SHA"
else
echo "Updating OMICRON_VERSION: $OLD_SHA -> $NEW_SHA"
echo "$NEW_SHA" > OMICRON_VERSION
fi

npm run gen-api
Loading