Skip to content

Commit 67127f7

Browse files
authored
Merge pull request #85 from imagekit-developer/stainless/release
Release SDK updates
2 parents 64e681a + 9d94fb4 commit 67127f7

10 files changed

Lines changed: 158 additions & 53 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
lint:
1919
timeout-minutes: 10
2020
name: lint
21-
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
21+
runs-on: ubuntu-latest
2222
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
2323
steps:
2424
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -44,7 +44,7 @@ jobs:
4444
permissions:
4545
contents: read
4646
id-token: write
47-
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
47+
runs-on: ubuntu-latest
4848
steps:
4949
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5050

@@ -61,44 +61,3 @@ jobs:
6161

6262
- name: Run build
6363
run: rye build
64-
65-
- name: Get GitHub OIDC Token
66-
if: |-
67-
github.repository == 'stainless-sdks/imagekit-python' &&
68-
!startsWith(github.ref, 'refs/heads/stl/')
69-
id: github-oidc
70-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
71-
with:
72-
script: core.setOutput('github_token', await core.getIDToken());
73-
74-
- name: Upload tarball
75-
if: |-
76-
github.repository == 'stainless-sdks/imagekit-python' &&
77-
!startsWith(github.ref, 'refs/heads/stl/')
78-
env:
79-
URL: https://pkg.stainless.com/s
80-
AUTH: ${{ steps.github-oidc.outputs.github_token }}
81-
SHA: ${{ github.sha }}
82-
run: ./scripts/utils/upload-artifact.sh
83-
84-
test:
85-
timeout-minutes: 10
86-
name: test
87-
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
88-
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
89-
steps:
90-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
91-
92-
- name: Install Rye
93-
run: |
94-
curl -sSf https://rye.astral.sh/get | bash
95-
echo "$HOME/.rye/shims" >> $GITHUB_PATH
96-
env:
97-
RYE_VERSION: '0.44.0'
98-
RYE_INSTALL_OPTION: '--yes'
99-
100-
- name: Bootstrap
101-
run: ./scripts/bootstrap
102-
103-
- name: Run tests
104-
run: ./scripts/test

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ jobs:
1818
run: |
1919
bash ./bin/check-release-environment
2020
env:
21+
RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
2122
PYPI_TOKEN: ${{ secrets.IMAGE_KIT_PYPI_TOKEN || secrets.PYPI_TOKEN }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Please
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
release-please:
13+
if: github.repository == 'imagekit-developer/imagekit-python'
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1
18+
id: release
19+
with:
20+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}

.github/workflows/stlc-promote.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Promote SDKs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
promote:
12+
runs-on: ubuntu-latest
13+
env:
14+
PRODUCTION_REPO: imagekit-developer/imagekit-python
15+
PRODUCTION_BRANCH: master
16+
GH_TOKEN: ${{ secrets.SDK_WRITE_TOKEN }}
17+
steps:
18+
- name: Check out staging
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
persist-credentials: false
23+
24+
- name: Fetch production main
25+
run: |
26+
git remote add production \
27+
"https://x-access-token:${GH_TOKEN}@github.com/${PRODUCTION_REPO}.git"
28+
git fetch production "${PRODUCTION_BRANCH}"
29+
30+
- name: Check if production is already in sync
31+
id: diff
32+
run: |
33+
STAGING_SHA=$(git rev-parse origin/main)
34+
PRODUCTION_SHA=$(git rev-parse production/${PRODUCTION_BRANCH})
35+
if [ "$STAGING_SHA" = "$PRODUCTION_SHA" ]; then
36+
echo "Production is already at $STAGING_SHA. Nothing to release."
37+
echo "synced=true" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "synced=false" >> "$GITHUB_OUTPUT"
40+
fi
41+
42+
- name: Push staging main to the release branch on production
43+
if: steps.diff.outputs.synced == 'false'
44+
run: |
45+
git push production origin/main:refs/heads/stainless/release --force
46+
47+
- name: Open or update the release PR on production
48+
if: steps.diff.outputs.synced == 'false'
49+
run: |
50+
EXISTING_PR=$(gh pr list \
51+
--repo "${PRODUCTION_REPO}" \
52+
--head stainless/release \
53+
--state open \
54+
--json number \
55+
--jq '.[0].number')
56+
if [ -z "${EXISTING_PR}" ]; then
57+
gh pr create \
58+
--repo "${PRODUCTION_REPO}" \
59+
--base "${PRODUCTION_BRANCH}" \
60+
--head stainless/release \
61+
--title "Release SDK updates" \
62+
--body "$(git log --oneline production/${PRODUCTION_BRANCH}..origin/main)"
63+
else
64+
echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it."
65+
fi
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Sync Release-As from release PR title
2+
3+
on:
4+
pull_request:
5+
types: [edited]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
sync:
12+
if: >-
13+
github.event.pull_request.base.ref == 'master' &&
14+
startsWith(github.event.pull_request.head.ref, 'release-please--') &&
15+
github.event.changes.title != null
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Extract versions from old and new title
19+
id: parse
20+
env:
21+
NEW_TITLE: ${{ github.event.pull_request.title }}
22+
OLD_TITLE: ${{ github.event.changes.title.from }}
23+
run: |
24+
# Anchored on pull-request-title-pattern "release: ${version}" from release-please-config.json.
25+
extract() {
26+
echo "$1" | grep -oE '^release:[[:space:]]+v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' \
27+
| sed -E 's/^release:[[:space:]]+v?//'
28+
}
29+
NEW_VERSION=$(extract "$NEW_TITLE")
30+
OLD_VERSION=$(extract "$OLD_TITLE")
31+
echo "old=$OLD_VERSION"
32+
echo "new=$NEW_VERSION"
33+
if [ -z "$NEW_VERSION" ]; then
34+
echo "::notice::No semver in new title; nothing to do."
35+
echo "skip=true" >> "$GITHUB_OUTPUT"
36+
exit 0
37+
fi
38+
if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then
39+
echo "::notice::Version unchanged ($NEW_VERSION); not pushing."
40+
echo "skip=true" >> "$GITHUB_OUTPUT"
41+
exit 0
42+
fi
43+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
44+
45+
- name: Check out master
46+
if: steps.parse.outputs.skip != 'true'
47+
uses: actions/checkout@v6
48+
with:
49+
ref: master
50+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
51+
fetch-depth: 1
52+
53+
- name: Push empty Release-As commit
54+
if: steps.parse.outputs.skip != 'true'
55+
env:
56+
VERSION: ${{ steps.parse.outputs.version }}
57+
run: |
58+
git config user.name "release-as-bot"
59+
git config user.email "release-as-bot@users.noreply.github.com"
60+
git commit --allow-empty -m "chore: pin next release
61+
62+
Release-As: ${VERSION}"
63+
git push origin master

.stats.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
configured_endpoints: 48
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-01267e4c07ec30011b8445babed88fbd2133b65198f42d0310b7ab39c74751d4.yml
3-
openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d
4-
config_hash: 7ef70b333059ca21bef0f0a6d4cbb282

bin/check-release-environment

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
errors=()
44

5+
if [ -z "${RELEASE_PLEASE_TOKEN}" ]; then
6+
errors+=("The RELEASE_PLEASE_TOKEN secret has not been set. Create a fine-grained GitHub PAT and add it as a repository secret.")
7+
fi
8+
59
if [ -z "${PYPI_TOKEN}" ]; then
610
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
711
fi

release-please-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"packages": {
33
".": {}
44
},
5-
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
5+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
66
"include-v-in-tag": true,
77
"include-component-in-tag": false,
88
"versioning": "prerelease",
9-
"prerelease": true,
9+
"prerelease": false,
1010
"bump-minor-pre-major": true,
1111
"bump-patch-for-minor-pre-major": false,
1212
"pull-request-header": "Automated Release PR",

scripts/utils/upload-artifact.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ UPLOAD_RESPONSE=$(curl -v -X PUT \
2020

2121
if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
2222
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
23-
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/imagekit-python/$SHA/$FILENAME'\033[0m"
23+
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/imagekit-python-staging/$SHA/$FILENAME'\033[0m"
2424
else
2525
echo -e "\033[31mFailed to upload artifact.\033[0m"
2626
exit 1

src/imagekit/lib/.keep

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)