Skip to content

Commit 6455528

Browse files
fix: add create release workflow
1 parent c9025f7 commit 6455528

File tree

4 files changed

+82
-3
lines changed

4 files changed

+82
-3
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Create releases
2+
on:
3+
schedule:
4+
- cron: '0 5 * * *' # every day at 5am UTC
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
name: release
12+
if: github.ref == 'refs/heads/main' && github.repository == 'anthropics/anthropic-sdk-php'
13+
runs-on: ubuntu-latest
14+
environment: production-release
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: stainless-api/trigger-release-please@v1
20+
id: release
21+
with:
22+
repo: ${{ github.event.repository.full_name }}
23+
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
24+
25+
- name: Publish to Packagist
26+
if: ${{ steps.release.outputs.releases_created }}
27+
run: |-
28+
curl --fail-with-body -X POST -H 'Content-Type: application/json' "https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_SAFE_KEY}" -d '{"repository":"https://www.github.com/anthropics/anthropic-sdk-php"}'
29+
env:
30+
PACKAGIST_USERNAME: ${{ secrets.ANTHROPIC_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }}
31+
PACKAGIST_SAFE_KEY: ${{ secrets.ANTHROPIC_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }}

.github/workflows/publish-packagist.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Publish Packagist
22
on:
33
workflow_dispatch:
4-
push:
5-
branches:
6-
- main
74

85
jobs:
96
publish:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release Doctor
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
release_doctor:
10+
name: release doctor
11+
runs-on: ubuntu-latest
12+
environment: production-release
13+
if: github.repository == 'anthropics/anthropic-sdk-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Check release environment
19+
run: |
20+
bash ./bin/check-release-environment
21+
env:
22+
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }}

bin/check-release-environment

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
errors=()
4+
5+
if [ -z "${STAINLESS_API_KEY}" ]; then
6+
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
7+
fi
8+
9+
if [ -z "${PACKAGIST_USERNAME}" ]; then
10+
errors+=("The PACKAGIST_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
11+
fi
12+
13+
if [ -z "${PACKAGIST_SAFE_KEY}" ]; then
14+
errors+=("The PACKAGIST_SAFE_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
15+
fi
16+
17+
lenErrors=${#errors[@]}
18+
19+
if [[ lenErrors -gt 0 ]]; then
20+
echo -e "Found the following errors in the release environment:\n"
21+
22+
for error in "${errors[@]}"; do
23+
echo -e "- $error\n"
24+
done
25+
26+
exit 1
27+
fi
28+
29+
echo "The environment is ready to push releases!"

0 commit comments

Comments
 (0)