Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.
Closed
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
147 changes: 147 additions & 0 deletions .github/workflows/auto-publish-sdks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Auto Publish SDKs

on:
workflow_call:

jobs:
check-python:
runs-on: ubuntu-latest
outputs:
needs_publish: ${{ steps.check.outputs.needs_publish }}
version: ${{ steps.check.outputs.version }}
checksum: ${{ steps.check.outputs.checksum }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if Python SDK needs publishing
id: check
run: |
if [ ! -f "generated-sdks/python/.source-checksum" ]; then
echo "No .source-checksum file found for Python SDK"
echo "needs_publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi

SOURCE_CHECKSUM=$(cat generated-sdks/python/.source-checksum)
echo "Source checksum: $SOURCE_CHECKSUM"

if git tag -l | grep -q "^sdk-python-v.*-${SOURCE_CHECKSUM}$"; then
echo "Tag with checksum already exists, skipping publish"
echo "needs_publish=false" >> "$GITHUB_OUTPUT"
else
echo "No tag found with this checksum, will publish"
echo "needs_publish=true" >> "$GITHUB_OUTPUT"
echo "checksum=$SOURCE_CHECKSUM" >> "$GITHUB_OUTPUT"

PUBLISHED_VERSION=$(curl -sf https://pypi.org/pypi/system-initiative-api-client/json | jq -r '.info.version')
if [ -z "$PUBLISHED_VERSION" ] || [ "$PUBLISHED_VERSION" == "null" ]; then
echo "::error::Failed to get published version from PyPI"
exit 1
fi
echo "Published version: $PUBLISHED_VERSION"

IFS='.' read -r MAJOR MINOR PATCH <<< "$PUBLISHED_VERSION"
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
fi

publish-python:
needs: check-python
if: needs.check-python.outputs.needs_publish == 'true'
uses: ./.github/workflows/publish-python-sdk.yml
with:
version: ${{ needs.check-python.outputs.version }}
secrets: inherit

tag-python:
runs-on: ubuntu-latest
needs: [check-python, publish-python]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.SYSTEMINIT_BOT_TOKEN }}

- name: Create tag
run: |
TAG_NAME="sdk-python-v${{ needs.check-python.outputs.version }}-${{ needs.check-python.outputs.checksum }}"
git config user.name "systeminitbot"
git config user.email "systeminitbot@systeminit.com"
git tag -a "$TAG_NAME" -m "Python SDK v${{ needs.check-python.outputs.version }} published"
git push origin "$TAG_NAME"
echo "Created tag: $TAG_NAME"

check-typescript:
runs-on: ubuntu-latest
outputs:
needs_publish: ${{ steps.check.outputs.needs_publish }}
version: ${{ steps.check.outputs.version }}
checksum: ${{ steps.check.outputs.checksum }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if TypeScript SDK needs publishing
id: check
run: |
if [ ! -f "generated-sdks/typescript/.source-checksum" ]; then
echo "No .source-checksum file found for TypeScript SDK"
echo "needs_publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi

SOURCE_CHECKSUM=$(cat generated-sdks/typescript/.source-checksum)
echo "Source checksum: $SOURCE_CHECKSUM"

if git tag -l | grep -q "^sdk-typescript-v.*-${SOURCE_CHECKSUM}$"; then
echo "Tag with checksum already exists, skipping publish"
echo "needs_publish=false" >> "$GITHUB_OUTPUT"
else
echo "No tag found with this checksum, will publish"
echo "needs_publish=true" >> "$GITHUB_OUTPUT"
echo "checksum=$SOURCE_CHECKSUM" >> "$GITHUB_OUTPUT"

PUBLISHED_VERSION=$(npm view system-initiative-api-client version)
if [ -z "$PUBLISHED_VERSION" ]; then
echo "::error::Failed to get published version from NPM"
exit 1
fi
echo "Published version: $PUBLISHED_VERSION"

IFS='.' read -r MAJOR MINOR PATCH <<< "$PUBLISHED_VERSION"
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
fi

publish-typescript:
needs: check-typescript
if: needs.check-typescript.outputs.needs_publish == 'true'
uses: ./.github/workflows/publish-typescript-sdk.yml
with:
version: ${{ needs.check-typescript.outputs.version }}
secrets: inherit

tag-typescript:
runs-on: ubuntu-latest
needs: [check-typescript, publish-typescript]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.SYSTEMINIT_BOT_TOKEN }}

- name: Create tag
run: |
TAG_NAME="sdk-typescript-v${{ needs.check-typescript.outputs.version }}-${{ needs.check-typescript.outputs.checksum }}"
git config user.name "systeminitbot"
git config user.email "systeminitbot@systeminit.com"
git tag -a "$TAG_NAME" -m "TypeScript SDK v${{ needs.check-typescript.outputs.version }} published"
git push origin "$TAG_NAME"
echo "Created tag: $TAG_NAME"
5 changes: 5 additions & 0 deletions .github/workflows/prod-deploy-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ jobs:
environment: production
wait_duration: 0
secrets: inherit

auto-publish-sdks:
needs: deploy-production
uses: ./.github/workflows/auto-publish-sdks.yml
secrets: inherit
10 changes: 8 additions & 2 deletions .github/workflows/publish-python-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
description: "Version to publish (e.g., 1.0.0)"
required: true
type: string
workflow_call:
inputs:
version:
description: "Version to publish (e.g., 1.0.0)"
required: true
type: string

jobs:
build-and-publish:
Expand All @@ -32,11 +38,11 @@ jobs:

- name: Update version in setup.py
run: |
sed -i "s/VERSION = ['\"].*['\"]/VERSION = '${{ github.event.inputs.version }}'/g" setup.py
sed -i "s/VERSION = ['\"].*['\"]/VERSION = '${{ inputs.version }}'/g" setup.py

- name: Update version in pyproject.toml
run: |
sed -i "s/version = ['\"].*['\"]/version = '${{ github.event.inputs.version }}'/g" pyproject.toml
sed -i "s/version = ['\"].*['\"]/version = '${{ inputs.version }}'/g" pyproject.toml

- name: Build package
run: python -m build
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/publish-typescript-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
description: "Version to publish (e.g., 1.0.0)"
required: true
type: string
workflow_call:
inputs:
version:
description: "Version to publish (e.g., 1.0.0)"
required: true
type: string

jobs:
build-and-publish-npm:
Expand All @@ -29,7 +35,7 @@ jobs:
- name: Update version in package.json
working-directory: generated-sdks/typescript
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/g" package.json
sed -i "s/\"version\": \".*\"/\"version\": \"${{ inputs.version }}\"/g" package.json
Comment thread
stack72 marked this conversation as resolved.
cat package.json

- name: Build package
Expand Down Expand Up @@ -69,7 +75,7 @@ jobs:
- name: Update version in deno.json
working-directory: generated-sdks/typescript
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/g" deno.json
sed -i "s/\"version\": \".*\"/\"version\": \"${{ inputs.version }}\"/g" deno.json
cat deno.json

- name: Build package
Expand Down
1 change: 1 addition & 0 deletions generated-sdks/python/.source-checksum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a3b77dab70f8b3bb90332db05d7ab49ca3069a035903c58a10d9e8ff13d4a9a1
1 change: 1 addition & 0 deletions generated-sdks/typescript/.source-checksum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cbb96a1848fdd8a1def0a98000c83a1b9e1c5115393a06c74791e2f91d871808
21 changes: 21 additions & 0 deletions generated-sdks/update-sdks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ set -euo pipefail
REPO_ROOT=$(buck2 root)
ACTUAL_SCRIPT_DIR="$REPO_ROOT/generated-sdks"

generate_checksum() {
local sdk_type=$1
local target_dir="$ACTUAL_SCRIPT_DIR/${sdk_type}"
local checksum_file="$target_dir/.source-checksum"

echo "Generating checksum for ${sdk_type} SDK..."

if [ "$sdk_type" == "python" ]; then
# Hash all .py files in the client package (excluding tests)
find "$target_dir/system_initiative_api_client" -name "*.py" -type f | sort | xargs sha256sum | sha256sum | cut -d' ' -f1 > "$checksum_file"
elif [ "$sdk_type" == "typescript" ]; then
# Hash all .ts files
find "$target_dir" -name "*.ts" -type f | sort | xargs sha256sum | sha256sum | cut -d' ' -f1 > "$checksum_file"
fi

echo "Checksum written to $checksum_file: $(cat "$checksum_file")"
}

update_sdk() {
local sdk_type=$1
local target_name="generate_${sdk_type}_sdk"
Expand All @@ -27,6 +45,9 @@ update_sdk() {
fi

echo "${sdk_type} SDK updated in $TARGET_DIR"

# Generate checksum after updating
generate_checksum "$sdk_type"
Comment thread
stack72 marked this conversation as resolved.
}

echo "Updating all SDKs..."
Expand Down
Loading