Skip to content

Release Production (SDK) #3

Release Production (SDK)

Release Production (SDK) #3

name: Release Production (SDK)
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
id-token: write
jobs:
# First job: Prepare production release
prepare-and-commit-prod:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump_version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/setup-project
- name: Calculate and update production version
id: bump_version
run: |
cd sdk
# Get current version and bump it
CURRENT_VERSION=$(bun -e "console.log(require('./package.json').version)")
echo "Current version: $CURRENT_VERSION"
# Bump version using Node.js semver since npm doesn't work with workspace: protocol
NEW_VERSION=$(node -e "
const fs = require('fs');
const semver = require('semver');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const newVersion = semver.inc(pkg.version, '${{ inputs.version_type }}');
pkg.version = newVersion;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');
console.log(newVersion);
")
echo "New production version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit and push version bump
run: |
git stash
git pull --rebase origin main
git stash pop
git add sdk/package.json
git commit -m "Bump SDK version to ${{ steps.bump_version.outputs.new_version }}"
git push
- name: Create and push production tag
run: |
git tag "sdk-v${{ steps.bump_version.outputs.new_version }}"
git push origin "sdk-v${{ steps.bump_version.outputs.new_version }}"
- name: Upload updated package
uses: actions/upload-artifact@v4
with:
name: updated-sdk-package
path: sdk/
build-and-publish-sdk:
needs: prepare-and-commit-prod
uses: ./.github/workflows/sdk-release-build.yml
with:
new-version: ${{ needs.prepare-and-commit-prod.outputs.new_version }}
artifact-name: updated-sdk-package
checkout-ref: ${{ github.sha }}
secrets: inherit