Skip to content

Commit

Permalink
fix(ts): does not mark ts release as latest in github
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Apr 14, 2024
1 parent 9452e22 commit b3e5145
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
6 changes: 1 addition & 5 deletions make/release-ts.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
.PHONY: release-ts
release-ts: $(AKASH_TS_NODE_MODULES) $(AKASH_TS_ROOT)/dist
if [ -z "$$CI" ]; then \
cd $(AKASH_TS_ROOT) && npx semantic-release --no-ci; \
else \
cd $(AKASH_TS_ROOT) && npx semantic-release; \
fi
script/release-ts.sh

$(AKASH_TS_ROOT)/dist: $(shell find $(AKASH_TS_ROOT)/src -type f)
cd $(AKASH_TS_ROOT) && npm run build
42 changes: 42 additions & 0 deletions script/release-ts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

API_URL="https://api.github.com"

log() {
echo "$(date +"[%I:%M:%S %p]") [ts-release] $1"
}

log "Fetching the current latest release information..."
current_latest=$(curl -s -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
"$API_URL/repos/$GITHUB_ACTION_REPOSITORY/releases/latest")
current_latest_id=$(echo "$current_latest" | jq -r '.id')

if [ "$current_latest_id" == "null" ]; then
log "No current latest release found."
exit 1
else
log "Current latest release ID: $current_latest_id"
fi

log "Running semantic-release..."
if [ -z "$CI" ]; then
log "Running in non-CI mode..."
cd "$AKASH_TS_ROOT" && npx semantic-release --no-ci
else
log "Running in CI mode..."
cd "$AKASH_TS_ROOT" && npx semantic-release
fi

log "Attempting to mark the release (ID: $current_latest_id) as the latest again..."
update_response=$(curl -s -X PATCH -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" \
-d "{\"make_latest\": \"true\"}" \
"$API_URL/repos/$GITHUB_ACTION_REPOSITORY/releases/$current_latest_id")

log "Update response:"
echo "$update_response" | jq

if echo "$update_response" | jq -e '.id'; then
log "The release was successfully marked as the latest."
else
log "Failed to update the release. Check the response above for errors."
fi
2 changes: 1 addition & 1 deletion ts/.releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"working_directory": "ts",
"branches": [
{
"name": "main"
"name": "chore/ts"
}
],
"tagFormat": "ts/v${version}"
Expand Down

0 comments on commit b3e5145

Please sign in to comment.