Skip to content

Release Cairo Coder #10

Release Cairo Coder

Release Cairo Coder #10

Workflow file for this run

name: Release Cairo Coder
on:
workflow_dispatch:
inputs:
release-type:
description: Type of release
required: true
type: choice
options:
- patch
- minor
- major
default: minor
permissions:
contents: write
packages: write
jobs:
update-version:
runs-on: ubuntu-latest
outputs:
new-version: ${{ steps.version.outputs.new-version }}
new-tag: ${{ steps.version.outputs.new-tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.ADMIN_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Update version and create tag
id: version
run: |
# Get current version from pyproject.toml
CURRENT_VERSION=$(uvx --from toml-cli toml get --toml-path python/pyproject.toml project.version)
# Calculate new version based on release type
IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION"
major="${version_parts[0]}"
minor="${version_parts[1]}"
patch="${version_parts[2]}"
if [ "${{ inputs.release-type }}" = "major" ]; then
major=$((major + 1))
minor=0
patch=0
elif [ "${{ inputs.release-type }}" = "minor" ]; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
NEW_VERSION="${major}.${minor}.${patch}"
# Update version in pyproject.toml
uvx --from toml-cli toml set --toml-path python/pyproject.toml project.version "$NEW_VERSION"
# Update version in ingesters/package.json
tmp_json=$(mktemp)
jq --arg version "$NEW_VERSION" '.version = $version' ingesters/package.json > "$tmp_json"
mv "$tmp_json" ingesters/package.json
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "new-tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
echo "NEW_VERSION=$NEW_VERSION"
echo "NEW_TAG=v$NEW_VERSION"
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
git add python/pyproject.toml ingesters/package.json
git commit -m "release: v$NEW_VERSION"
git tag "v$NEW_VERSION"
git push origin HEAD --tags
build-new-image:
needs: update-version
uses: ./.github/workflows/publish-image.yml
with:
release-tag: ${{ needs.update-version.outputs.new-tag }}
secrets: inherit
create-release:
needs: [update-version, build-new-image]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create draft release
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/scripts/create-release.js');
await script({ github, context });
env:
NEW_TAG: ${{ needs.update-version.outputs.new-tag }}
REPOSITORY: ${{ github.repository }}