diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa5d164b..26e6e002 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,48 +15,10 @@ on: - 'stl-preview-base/**' jobs: - build: - timeout-minutes: 10 - name: build - permissions: - contents: read - id-token: write - runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: |- - github.repository == 'stainless-sdks/imagekit-ruby' && - (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 - - name: Set up Ruby - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 - with: - bundler-cache: false - - run: |- - bundle install - - - name: Get GitHub OIDC Token - if: |- - github.repository == 'stainless-sdks/imagekit-ruby' && - !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: Build and upload gem artifacts - if: |- - github.repository == 'stainless-sdks/imagekit-ruby' && - !startsWith(github.ref, 'refs/heads/stl/') - env: - URL: https://pkg.stainless.com/s - AUTH: ${{ steps.github-oidc.outputs.github_token }} - SHA: ${{ github.sha }} - PACKAGE_NAME: imagekitio - run: ./scripts/utils/upload-artifact.sh lint: timeout-minutes: 10 name: lint - runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: @@ -70,19 +32,3 @@ jobs: - name: Run lints run: ./scripts/lint - test: - timeout-minutes: 10 - name: test - runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && '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: Set up Ruby - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 - with: - bundler-cache: false - - run: |- - bundle install - - - name: Run tests - run: ./scripts/test diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index bd2fe0ef..4cbe3745 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -18,5 +18,6 @@ jobs: run: | bash ./bin/check-release-environment env: + RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }} RUBYGEMS_HOST: ${{ secrets.IMAGE_KIT_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }} GEM_HOST_API_KEY: ${{ secrets.IMAGE_KIT_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..e16260f9 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,20 @@ +name: Release Please +on: + push: + branches: + - master + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + if: github.repository == 'imagekit-developer/imagekit-ruby' + runs-on: ubuntu-latest + + steps: + - uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1 + id: release + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} diff --git a/.github/workflows/stlc-promote.yml b/.github/workflows/stlc-promote.yml new file mode 100644 index 00000000..3ff16d5b --- /dev/null +++ b/.github/workflows/stlc-promote.yml @@ -0,0 +1,65 @@ +name: Promote SDKs + +on: + push: + branches: [main] + +permissions: + contents: read + +jobs: + promote: + runs-on: ubuntu-latest + env: + PRODUCTION_REPO: imagekit-developer/imagekit-ruby + PRODUCTION_BRANCH: master + GH_TOKEN: ${{ secrets.SDK_WRITE_TOKEN }} + steps: + - name: Check out staging + uses: actions/checkout@v4 + 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 "${PRODUCTION_BRANCH}" + + - name: Check if production is already in sync + id: diff + run: | + STAGING_SHA=$(git rev-parse origin/main) + PRODUCTION_SHA=$(git rev-parse production/${PRODUCTION_BRANCH}) + 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/stainless/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 stainless/release \ + --state open \ + --json number \ + --jq '.[0].number') + if [ -z "${EXISTING_PR}" ]; then + gh pr create \ + --repo "${PRODUCTION_REPO}" \ + --base "${PRODUCTION_BRANCH}" \ + --head stainless/release \ + --title "Release SDK updates" \ + --body "$(git log --oneline production/${PRODUCTION_BRANCH}..origin/main)" + else + echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it." + fi diff --git a/.github/workflows/sync-release-as.yml b/.github/workflows/sync-release-as.yml new file mode 100644 index 00000000..99150044 --- /dev/null +++ b/.github/workflows/sync-release-as.yml @@ -0,0 +1,63 @@ +name: Sync Release-As from release PR title + +on: + pull_request: + types: [edited] + +permissions: + contents: write + +jobs: + sync: + if: >- + github.event.pull_request.base.ref == 'master' && + startsWith(github.event.pull_request.head.ref, 'release-please--') && + github.event.changes.title != null + runs-on: ubuntu-latest + steps: + - name: Extract versions from old and new title + id: parse + env: + NEW_TITLE: ${{ github.event.pull_request.title }} + OLD_TITLE: ${{ github.event.changes.title.from }} + run: | + # Anchored on pull-request-title-pattern "release: ${version}" from release-please-config.json. + extract() { + echo "$1" | grep -oE '^release:[[:space:]]+v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' \ + | sed -E 's/^release:[[:space:]]+v?//' + } + NEW_VERSION=$(extract "$NEW_TITLE") + OLD_VERSION=$(extract "$OLD_TITLE") + echo "old=$OLD_VERSION" + echo "new=$NEW_VERSION" + if [ -z "$NEW_VERSION" ]; then + echo "::notice::No semver in new title; nothing to do." + echo "skip=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then + echo "::notice::Version unchanged ($NEW_VERSION); not pushing." + echo "skip=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + + - name: Check out master + if: steps.parse.outputs.skip != 'true' + uses: actions/checkout@v6 + with: + ref: master + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + fetch-depth: 1 + + - name: Push empty Release-As commit + if: steps.parse.outputs.skip != 'true' + env: + VERSION: ${{ steps.parse.outputs.version }} + run: | + git config user.name "release-as-bot" + git config user.email "release-as-bot@users.noreply.github.com" + git commit --allow-empty -m "chore: pin next release + + Release-As: ${VERSION}" + git push origin master diff --git a/.stats.yml b/.stats.yml index 88ec6965..006b15f4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-b9cc1f62fca41c286295001551cbe902d6b2f30ab775d84e549eb5affc0186ec.yml -openapi_spec_hash: f3790446521a8f846e2e7249313de100 -config_hash: c5a7aed248c5d9ad5cd42e56fdd62c12 diff --git a/Gemfile.lock b/Gemfile.lock index 045ec1f6..fdbab266 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -144,7 +144,7 @@ GEM rexml (>= 3.2.6) sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) - standardwebhooks (1.1.0) + standardwebhooks (1.0.1) steep (1.10.0) activesupport (>= 5.1) concurrent-ruby (>= 1.1.10) diff --git a/bin/check-release-environment b/bin/check-release-environment index c05436e8..4ec6c753 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -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 "${GEM_HOST_API_KEY}" ]; then errors+=("The GEM_HOST_API_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi diff --git a/lib/imagekitio/client.rb b/lib/imagekitio/client.rb index b4bfd22a..6b3ec5ee 100644 --- a/lib/imagekitio/client.rb +++ b/lib/imagekitio/client.rb @@ -28,7 +28,7 @@ class Client < Imagekitio::Internal::Transport::BaseClient # Your ImageKit webhook secret for verifying webhook signatures (starts with # `whsec_`). You can find this in the # [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only - # required if you're using webhooks. + # required if you are using webhooks. # @return [String, nil] attr_reader :webhook_secret @@ -90,7 +90,7 @@ def base_url_overridden? = @base_url_overridden # @param webhook_secret [String, nil] Your ImageKit webhook secret for verifying webhook signatures (starts with # `whsec_`). You can find this in the # [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only - # required if you're using webhooks. Defaults to `ENV["IMAGEKIT_WEBHOOK_SECRET"]` + # required if you are using webhooks. Defaults to `ENV["IMAGEKIT_WEBHOOK_SECRET"]` # # @param base_url [String, nil] Override the default base URL for the API, e.g., # `"https://api.example.com/v2/"`. Defaults to `ENV["IMAGE_KIT_BASE_URL"]` diff --git a/rbi/imagekitio/client.rbi b/rbi/imagekitio/client.rbi index a0e151fa..90f1116e 100644 --- a/rbi/imagekitio/client.rbi +++ b/rbi/imagekitio/client.rbi @@ -23,7 +23,7 @@ module Imagekitio # Your ImageKit webhook secret for verifying webhook signatures (starts with # `whsec_`). You can find this in the # [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only - # required if you're using webhooks. + # required if you are using webhooks. sig { returns(T.nilable(String)) } attr_reader :webhook_secret @@ -92,7 +92,7 @@ module Imagekitio # Your ImageKit webhook secret for verifying webhook signatures (starts with # `whsec_`). You can find this in the # [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only - # required if you're using webhooks. Defaults to `ENV["IMAGEKIT_WEBHOOK_SECRET"]` + # required if you are using webhooks. Defaults to `ENV["IMAGEKIT_WEBHOOK_SECRET"]` webhook_secret: ENV["IMAGEKIT_WEBHOOK_SECRET"], # Override the default base URL for the API, e.g., # `"https://api.example.com/v2/"`. Defaults to `ENV["IMAGE_KIT_BASE_URL"]` diff --git a/release-please-config.json b/release-please-config.json index 70a47571..a708bb63 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -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", @@ -62,9 +62,6 @@ "release-type": "ruby", "version-file": "lib/imagekitio/version.rb", "extra-files": [ - { - "type": "ruby-readme", - "path": "README.md" - } + "README.md" ] } \ No newline at end of file diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh index b2e36e9f..3a3b1f13 100755 --- a/scripts/utils/upload-artifact.sh +++ b/scripts/utils/upload-artifact.sh @@ -110,4 +110,4 @@ walk_tree "$DIST_DIR" echo "::endgroup::" echo -e "${GREEN}Gem artifacts uploaded to Stainless storage.${NC}" -echo -e "\033[32mInstallation: bundle remove imagekitio && bundle add imagekitio --source 'https://pkg.stainless.com/s/imagekit-ruby/$SHA'\033[0m" +echo -e "\033[32mInstallation: bundle remove imagekitio && bundle add imagekitio --source 'https://pkg.stainless.com/s/imagekit-ruby-staging/$SHA'\033[0m"