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
43 changes: 30 additions & 13 deletions .github/scripts/packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,37 @@ source_digest=''
published_tag=''

load_versions() {
local packages

packages=$(gh api --paginate --slurp \
"/orgs/MonadIAM/packages?package_type=container&per_page=100")

if jq -e --arg name "$PACKAGE" \
'any(.[][]; .name == $name)' <<< "$packages" >/dev/null; then
versions=$(gh api --paginate --slurp \
"$PACKAGE_API/versions?per_page=100" | jq 'add')
local page response status body url

versions='[]'
for ((page = 1; ; page++)); do
url="https://api.github.com$PACKAGE_API/versions?per_page=100&page=$page"
response=$(curl --silent --show-error \
--connect-timeout 5 --max-time 30 \
--header "Authorization: Bearer $GITHUB_TOKEN" \
--header "Accept: application/vnd.github+json" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--write-out $'\n%{http_code}' "$url")
status="${response##*$'\n'}"
body="${response%$'\n'*}"

if [[ "$status" == 200 ]]; then
versions=$(jq -c --argjson batch "$body" '. + $batch' <<< "$versions")
if [[ $(jq 'length' <<< "$body") -lt 100 ]]; then
break
fi
elif [[ "$status" == 404 && "$page" == 1 ]]; then
break
else
printf 'Failed to list package versions: GET %s; HTTP %s\n%s\n' \
"$url" "$status" "${body:0:4096}" >&2
exit 1
fi
done

source_digest=$(jq -r --arg tag "$sha_tag" '
.[] | select(.metadata.container.tags | index($tag)) | .name
' <<< "$versions")
fi
source_digest=$(jq -r --arg tag "$sha_tag" '
.[] | select(.metadata.container.tags | index($tag)) | .name
' <<< "$versions")
}

publish_commit() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Shared Kafka/gRPC contracts and common enums between MonadIAM services",
"author": "Daniil Egorov (https://github.com/Lambdius)",
"license": "UNLICENSED",
"version": "3.0.0",
"version": "3.0.1",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"exports": {
Expand Down
Loading