8000 chore(ci): upload sdks to package manager · cloudflare/cloudflare-python@c8af26d · GitHub
[go: up one dir, main page]

Skip to content

Commit c8af26d

Browse files
chore(ci): upload sdks to package manager
1 parent 6e80064 commit c8af26d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ jobs:
3535
- name: Run lints
3636
run: ./scripts/lint
3737

38+
upload:
39+
if: github.repository == 'stainless-sdks/cloudflare-python'
40+
timeout-minutes: 10
41+
name: upload
42+
permissions:
43+
contents: read
44+
id-token: write
45+
runs-on: depot-ubuntu-24.04
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Get GitHub OIDC Token
50+
id: github-oidc
51+
uses: actions/github-script@v6
52+
with:
53+
script: core.setOutput('github_token', await core.getIDToken());
54+
55+
- name: Upload tarball
56+
env:
57+
URL: https://pkg.stainless.com/s
58+
AUTH: ${{ steps.github-oidc.outputs.github_token }}
59+
SHA: ${{ github.sha }}
60+
run: ./scripts/utils/upload-artifact.sh
61+
3862
test:
3963
timeout-minutes: 10
4064
name: test

scripts/utils/upload-artifact.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -exuo pipefail
3+
4+
RESPONSE=$(curl -X POST "$URL" \
5+
-H "Authorization: Bearer $AUTH" \
6+
-H "Content-Type: application/json")
7+
8+
SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url')
9+
10+
if [[ "$SIGNED_URL" == "null" ]]; then
11+
echo -e "\033[31mFailed to get signed URL.\033[0m"
12+
exit 1
13+
fi
14+
15+
UPLOAD_RESPONSE=$(tar -cz . | curl -v -X PUT \
16+
-H "Content-Type: application/gzip" \
17+
--data-binary @- "$SIGNED_URL" 2>&1)
18+
19+
if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
20+
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
21+
echo -e "\033[32mInstallation: npm install 'https://pkg.stainless.com/s/cloudflare-python/$SHA'\033[0m"
22+
else
23+
echo -e "\033[31mFailed to upload artifact.\033[0m"
24+
exit 1
25+
fi

0 commit comments

Comments
 (0)
0