Skip to content

Commit bdf273c

Browse files
committed
combine sdk-release-prod and sdk-release-build into one file
1 parent c6989d9 commit bdf273c

File tree

3 files changed

+46
-83
lines changed

3 files changed

+46
-83
lines changed

.github/workflows/sdk-release-build.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ permissions:
1919

2020
jobs:
2121
# First job: Prepare production release
22-
prepare-and-commit-prod:
22+
release-sdk:
2323
runs-on: ubuntu-latest
2424
outputs:
2525
new_version: ${{ steps.bump_version.outputs.new_version }}
@@ -66,13 +66,46 @@ jobs:
6666
git stash pop
6767
git add sdk/package.json
6868
git commit -m "Bump SDK version to ${{ steps.bump_version.outputs.new_version }}"
69-
git push
7069
71-
build-and-publish-sdk:
72-
needs: prepare-and-commit-prod
73-
uses: ./.github/workflows/sdk-release-build.yml
74-
with:
75-
new-version: ${{ needs.prepare-and-commit-prod.outputs.new_version }}
76-
artifact-name: updated-sdk-package
77-
env-overrides: '{"OPEN_ROUTER_API_KEY": ".", "RELACE_API_KEY": ".", "LINKUP_API_KEY": ".", "GOOGLE_CLOUD_PROJECT_ID": ".", "PORT": "1000", "DATABASE_URL": ".", "CODEBUFF_GITHUB_ID": ".", "CODEBUFF_GITHUB_SECRET": ".", "NEXTAUTH_SECRET": ".", "STRIPE_SECRET_KEY": ".", "STRIPE_WEBHOOK_SECRET_KEY": ".", "STRIPE_USAGE_PRICE_ID": ".", "STRIPE_TEAM_FEE_PRICE_ID": ".", "LOOPS_API_KEY": ".", "DISCORD_PUBLIC_KEY": ".", "DISCORD_BOT_TOKEN": ".", "DISCORD_APPLICATION_ID": ".", "API_KEY_ENCRYPTION_SECRET": "................................", "NEXT_PUBLIC_CODEBUFF_BACKEND_URL": "manicode-backend.onrender.com", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
78-
secrets: inherit
70+
- name: Set environment variables
71+
env:
72+
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
73+
ENV_OVERRIDES: '{"NEXT_PUBLIC_CODEBUFF_BACKEND_URL": "manicode-backend.onrender.com", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
74+
shell: bash
75+
run: |
76+
VAR_NAMES=$(bun scripts/generate-ci-env.ts)
77+
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
78+
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
79+
' >> $GITHUB_ENV
80+
81+
# Set default environment variables
82+
echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV
83+
84+
echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV
85+
86+
# Apply environment variable overrides
87+
if [ "$ENV_OVERRIDES" != "{}" ]; then
88+
echo "$ENV_OVERRIDES" | jq -r 'to_entries | .[] | .key + "=" + .value' >> $GITHUB_ENV
89+
fi
90+
91+
- name: Build SDK
92+
run: |
93+
cd sdk
94+
bun run build:verify
95+
96+
- name: Set up Node.js for npm publishing
97+
uses: actions/setup-node@v4
98+
with:
99+
node-version: 20
100+
registry-url: https://registry.npmjs.org/
101+
102+
- name: Publish to npm
103+
run: |
104+
cd sdk
105+
bun run publish-sdk
106+
env:
107+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
108+
109+
- name: Push to git
110+
run: |
111+
git push

sdk/scripts/release.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function triggerWorkflow(versionType) {
5353
-H "Accept: application/vnd.github.v3+json" \
5454
-H "Authorization: token ${process.env.GITHUB_TOKEN}" \
5555
-H "Content-Type: application/json" \
56-
https://api.github.com/repos/CodebuffAI/codebuff/actions/workflows/sdk-release-prod.yml/dispatches \
56+
https://api.github.com/repos/CodebuffAI/codebuff/actions/workflows/sdk-release.yml/dispatches \
5757
-d '{"ref":"main","inputs":{"version_type":"${versionType}"}}'`
5858

5959
const response = execSync(triggerCmd, { encoding: 'utf8' })
@@ -63,15 +63,15 @@ async function triggerWorkflow(versionType) {
6363
log(`⚠️ Workflow dispatch failed: ${response}`)
6464
log('The workflow may need to be updated on GitHub. Continuing anyway...')
6565
log(
66-
'Please manually trigger the workflow at: https://github.com/CodebuffAI/codebuff/actions/workflows/sdk-release-prod.yml',
66+
'Please manually trigger the workflow at: https://github.com/CodebuffAI/codebuff/actions/workflows/sdk-release.yml',
6767
)
6868
} else {
6969
log('🎉 SDK release workflow triggered!')
7070
}
7171
} catch (err) {
7272
log(`⚠️ Failed to trigger workflow automatically: ${err.message}`)
7373
log(
74-
'You may need to trigger it manually at: https://github.com/CodebuffAI/codebuff/actions/workflows/sdk-release-prod.yml',
74+
'You may need to trigger it manually at: https://github.com/CodebuffAI/codebuff/actions/workflows/sdk-release.yml',
7575
)
7676
}
7777
}

0 commit comments

Comments
 (0)