Skip to content
Closed
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
53 changes: 52 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,57 @@ jobs:
name: publish package versions
command: |
bun ./publish-version.mjs
- run:
name: create GitHub release from version tag
command: |
if [ -z "$GH_TOKEN" ]; then
echo "GH_TOKEN is required to create GitHub releases."
exit 1
fi

if [ ! -f ./version.txt ]; then
echo "version.txt was not found; cannot create release."
exit 1
fi

VERSION=$(tr -d '\r\n' < ./version.txt)
TAG="v${VERSION}"
IS_PRERELEASE=false

if [ "$CIRCLE_BRANCH" = "beta" ]; then
IS_PRERELEASE=true
fi

RELEASE_PAYLOAD=$(cat \<<EOF
{
"tag_name": "${TAG}",
"target_commitish": "${CIRCLE_SHA1}",
"name": "${TAG}",
"body": "Automated release for ${TAG}",
"draft": false,
"prerelease": ${IS_PRERELEASE},
"generate_release_notes": true
}
EOF
)

HTTP_CODE=$(curl -sS -o /tmp/create-release-response.json -w "%{http_code}" \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/releases" \
-d "${RELEASE_PAYLOAD}")

if [ "$HTTP_CODE" = "201" ]; then
echo "Created GitHub release for ${TAG}."
elif [ "$HTTP_CODE" = "422" ]; then
echo "Release for ${TAG} already exists; treating as success."
else
echo "Failed to create release. HTTP status: $HTTP_CODE"
cat /tmp/create-release-response.json
exit 1
fi
- run:
name: Again set the NPM registry (was deleted in the version script)
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
Expand Down Expand Up @@ -167,7 +218,7 @@ workflows:
branches:
only:
- main
# - beta
- beta
- BUILD:
requires:
- CHECKOUT
Expand Down
2 changes: 0 additions & 2 deletions publish-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ async function run() {
'--message',
`chore(version): Update package versions to ${nextVersion} [skip ci]`,
'--conventional-commits',
'--create-release',
'github',
'--no-push',
]);

Expand Down
Loading