diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0260dd72c..2b00dac13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ on: - 'stl-preview-head/**' - 'stl-preview-base/**' +permissions: + contents: read + jobs: lint: timeout-minutes: 15 @@ -23,6 +26,8 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 @@ -42,14 +47,54 @@ jobs: build: timeout-minutes: 30 name: build + runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || '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') && + !(github.repository == 'stainless-sdks/openai-java' && + github.event_name == 'push' && + !startsWith(github.ref, 'refs/heads/stl/')) + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false + + - name: Set up Java + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@0b6dd653ba04f4f93bf581ec31e66cbd7dcb644d # v4 + + - name: Build SDK + # disable gradle daemon in CI because it is flakey + env: + GRADLE_OPTS: "-Dkotlin.compiler.execution.strategy=in-process" + run: ./scripts/build + + upload-maven-artifacts: + timeout-minutes: 30 + name: build-and-upload-maven-artifacts permissions: contents: read id-token: write - runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || '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') + runs-on: depot-ubuntu-24.04 + if: |- + github.repository == 'stainless-sdks/openai-java' && + github.event_name == 'push' && + github.event.head_commit.message != 'codegen metadata' && + !startsWith(github.ref, 'refs/heads/stl/') steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 @@ -69,10 +114,7 @@ jobs: GRADLE_OPTS: "-Dkotlin.compiler.execution.strategy=in-process" run: ./scripts/build - - name: Build and upload Maven artifacts - if: |- - github.repository == 'stainless-sdks/openai-java' && - !startsWith(github.ref, 'refs/heads/stl/') + - name: Upload Maven artifacts env: URL: https://pkg.stainless.com/s SHA: ${{ github.sha }} @@ -121,6 +163,8 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 @@ -141,10 +185,12 @@ jobs: name: examples environment: CI runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.repository == 'openai/openai-java' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') + if: github.repository == 'openai/openai-java' && github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.head_commit.message != 'codegen metadata' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml index 22de02113..27852eeac 100644 --- a/.github/workflows/create-releases.yml +++ b/.github/workflows/create-releases.yml @@ -6,6 +6,9 @@ on: branches: - main +permissions: + contents: read + jobs: release: name: release @@ -17,6 +20,8 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - uses: stainless-api/trigger-release-please@bb6677c5a04578eec1ccfd9e1913b5b78ed64c61 # v1.4.0 id: release @@ -33,6 +38,8 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 diff --git a/.github/workflows/detect-breaking-changes.yml b/.github/workflows/detect-breaking-changes.yml index e20819b1b..94819c587 100644 --- a/.github/workflows/detect-breaking-changes.yml +++ b/.github/workflows/detect-breaking-changes.yml @@ -5,6 +5,9 @@ on: - main - next +permissions: + contents: read + jobs: detect_breaking_changes: runs-on: 'ubuntu-latest' @@ -19,6 +22,7 @@ jobs: with: # Ensure we can check out the pull request base in the script below. fetch-depth: ${{ env.FETCH_DEPTH }} + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 @@ -36,4 +40,4 @@ jobs: # Try to check out previous versions of the breaking change detection script. This ensures that # we still detect breaking changes when entire files and their tests are removed. git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true - ./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }} \ No newline at end of file + ./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }} diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 92f560bde..c99d8eccd 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -4,6 +4,9 @@ name: Publish Sonatype on: workflow_dispatch: +permissions: + contents: read + jobs: publish: name: publish @@ -12,6 +15,8 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + persist-credentials: false - name: Set up Java uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5