Skip to content
Open
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
45 changes: 2 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/gcore-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -44,7 +44,7 @@ jobs:
permissions:
contents: read
id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/gcore-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

Expand All @@ -61,44 +61,3 @@ jobs:

- name: Run build
run: rye build

- name: Get GitHub OIDC Token
if: |-
github.repository == 'stainless-sdks/gcore-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: |-
github.repository == 'stainless-sdks/gcore-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
run: ./scripts/utils/upload-artifact.sh

test:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/gcore-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Bootstrap
run: ./scripts/bootstrap

- name: Run tests
run: ./scripts/test
1 change: 1 addition & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
PYPI_TOKEN: ${{ secrets.GCORE_PYPI_TOKEN || secrets.PYPI_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release Please
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-please:
if: github.repository == 'G-Core/gcore-python'
runs-on: ubuntu-latest

steps:
- uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1
id: release
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
89 changes: 89 additions & 0 deletions .github/workflows/seal-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Seal custom code (dispatch)

# When genuine out-of-band custom code is merged to this SDK repo's main,
# notify G-Core/stlc-config to reseal so the custom-code tracking JSON
# (the {base, integrated} commit pair) absorbs it. stlc-authored commits are
# skipped by the loop guard below, so the bot's own pushes (the "Build SDK"
# squash commit and the docs-regen commit) can't trigger a reseal loop.
#
# This workflow is itself custom code: it must be sealed once (stlc build
# --commit) to bootstrap, after which it is preserved across regenerations.
on:
push:
# main only. stlc preview/integrated/codegen branches never push to main,
# so listing main here already excludes them.
branches: [main]

concurrency:
group: seal-dispatch-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
dispatch:
runs-on: ubuntu-latest
# Canonical staging repo on the upstream only (never forks).
if: github.repository == 'G-Core/gcore-python-staging'
steps:
- name: Loop-guard and send reseal dispatch
env:
DISPATCH_TOKEN: ${{ secrets.STLC_CONFIG_DISPATCH_TOKEN }}
HEAD_MSG: ${{ github.event.head_commit.message }}
HEAD_AUTHOR_USERNAME: ${{ github.event.head_commit.author.username }}
HEAD_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
SHA: ${{ github.sha }}
REF: ${{ github.ref }}
ACTOR: ${{ github.actor }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail

# Loop guard 1: skip the stlc "Build SDK" squash commit (carries the
# Stainless-Generated-From trailer in its message).
if printf '%s' "$HEAD_MSG" | grep -q 'Stainless-Generated-From'; then
echo "Head commit carries Stainless-Generated-From trailer — skipping dispatch."
exit 0
fi

# Loop guard 2: skip stlc-bot commits (e.g. the docs-regen commit).
if [ "$HEAD_AUTHOR_USERNAME" = "stlc-bot" ] || [ "$HEAD_AUTHOR_NAME" = "stlc-bot" ]; then
echo "Head commit authored by stlc-bot — skipping dispatch."
exit 0
fi

if [ -z "${DISPATCH_TOKEN}" ]; then
echo "STLC_CONFIG_DISPATCH_TOKEN is not set — cannot send dispatch." >&2
exit 1
fi

# Reseal all targets (matches the commit-back scope on stlc-config).
cat > /tmp/dispatch-payload.json <<JSON
{
"event_type": "seal-custom-code",
"client_payload": {
"target": "all",
"sha": "${SHA}",
"ref": "${REF}",
"actor": "${ACTOR}",
"repo": "${REPO}"
}
}
JSON

echo "Sending seal-custom-code dispatch to G-Core/stlc-config for ${REPO}@${SHA}."
http_code=$(curl -sS -o /tmp/dispatch-resp.txt -w '%{http_code}' \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${DISPATCH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/G-Core/stlc-config/dispatches \
-d @/tmp/dispatch-payload.json)

if [ "$http_code" != "204" ]; then
echo "Dispatch failed with HTTP ${http_code}:" >&2
cat /tmp/dispatch-resp.txt >&2
exit 1
fi
echo "Dispatch accepted (HTTP 204)."
67 changes: 67 additions & 0 deletions .github/workflows/stlc-promote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Promote SDKs

on:
push:
branches: [main]

permissions:
contents: read

jobs:
promote:
runs-on: ubuntu-latest
# Canonical staging repo on the upstream only (never forks/prod).
if: github.repository == 'G-Core/gcore-python-staging'
env:
PRODUCTION_REPO: G-Core/gcore-python
GH_TOKEN: ${{ secrets.SDK_PROD_WRITE_TOKEN }}
steps:
- name: Check out staging
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Fetch production main
run: |
git remote add production \
"https://x-access-token:${GH_TOKEN}@github.com/${PRODUCTION_REPO}.git"
git fetch production main

- name: Check if production is already in sync
id: diff
run: |
STAGING_SHA=$(git rev-parse origin/main)
PRODUCTION_SHA=$(git rev-parse production/main)
if [ "$STAGING_SHA" = "$PRODUCTION_SHA" ]; then
echo "Production is already at $STAGING_SHA. Nothing to release."
echo "synced=true" >> "$GITHUB_OUTPUT"
else
echo "synced=false" >> "$GITHUB_OUTPUT"
fi

- name: Push staging main to the release branch on production
if: steps.diff.outputs.synced == 'false'
run: |
git push production origin/main:refs/heads/release --force

- name: Open or update the release PR on production
if: steps.diff.outputs.synced == 'false'
run: |
EXISTING_PR=$(gh pr list \
--repo "${PRODUCTION_REPO}" \
--head release \
--state open \
--json number \
--jq '.[0].number')
if [ -z "${EXISTING_PR}" ]; then
gh pr create \
--repo "${PRODUCTION_REPO}" \
--base main \
--head release \
--title "Release SDK updates" \
--body "$(git log --oneline production/main..origin/main)"
else
echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it."
fi

3 changes: 0 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
configured_endpoints: 659
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore/gcore-dd1d87ab049f38204f454bc0cc9faae580749fbe38c42aebd743ea895e349d52.yml
openapi_spec_hash: 56b7f9ac85a32a2db9de669906c2de81
config_hash: 98013df2c90b78c26ba57c91d767ebef
4 changes: 4 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

errors=()

if [ -z "${RELEASE_PLEASE_TOKEN}" ]; then
errors+=("The RELEASE_PLEASE_TOKEN secret has not been set. Create a fine-grained GitHub PAT and add it as a repository secret.")
fi

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi
Expand Down
4 changes: 2 additions & 2 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"packages": {
".": {}
},
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"include-v-in-tag": true,
"include-component-in-tag": false,
"versioning": "prerelease",
"prerelease": true,
"prerelease": false,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"pull-request-header": "Automated Release PR",
Expand Down
15 changes: 8 additions & 7 deletions scripts/mock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ UPLOAD_RESPONSE=$(curl -v -X PUT \

if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/gcore-python/$SHA/$FILENAME'\033[0m"
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/gcore-python-staging/$SHA/$FILENAME'\033[0m"
else
echo -e "\033[31mFailed to upload artifact.\033[0m"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions tests/api_resources/streaming/videos/test_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_method_update_with_all_params(self, client: Gcore) -> None:
subtitle = client.streaming.videos.subtitles.update(
id=0,
video_id=0,
language="ltz",
language="language",
name="name",
vtt="vtt",
)
Expand Down Expand Up @@ -291,7 +291,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncGcore) ->
subtitle = await async_client.streaming.videos.subtitles.update(
id=0,
video_id=0,
language="ltz",
language="language",
name="name",
vtt="vtt",
)
Expand Down
Loading