Skip to content

Merge pull request #232 from The-AI-Alliance/release/promote-cs-relfix #29

Merge pull request #232 from The-AI-Alliance/release/promote-cs-relfix

Merge pull request #232 from The-AI-Alliance/release/promote-cs-relfix #29

Workflow file for this run

name: Release and Publish to PyPI
on:
push:
tags:
- 'cube-standard/v*'
- 'cube-tools/*/v*'
- 'cube-resources/*/v*'
jobs:
create-github-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Idempotent: skip if release already exists (e.g. workflow re-run)
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG already exists, skipping."
else
gh release create "$TAG" --title "$TAG" --generate-notes
fi
publish-cube-standard:
if: startsWith(github.ref, 'refs/tags/cube-standard/')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
publish-cube-tool:
if: startsWith(github.ref, 'refs/tags/cube-tools/')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Resolve package directory
id: pkg
run: |
# Tag format: cube-tools/<package-name>/v1.2.3
TAG="${GITHUB_REF#refs/tags/}"
PKG_NAME=$(echo "$TAG" | cut -d'/' -f2)
PKG_DIR="cube-tools/$PKG_NAME"
if [ ! -f "$PKG_DIR/pyproject.toml" ]; then
echo "ERROR: $PKG_DIR/pyproject.toml not found. Is the tag correct?"
exit 1
fi
echo "name=$PKG_NAME" >> "$GITHUB_OUTPUT"
echo "dir=$PKG_DIR" >> "$GITHUB_OUTPUT"
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
- name: Build package
working-directory: ${{ steps.pkg.outputs.dir }}
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
with:
packages-dir: ${{ steps.pkg.outputs.dir }}/dist
publish-cube-resource:
if: startsWith(github.ref, 'refs/tags/cube-resources/')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Resolve package directory
id: pkg
run: |
# Tag format: cube-resources/<package-name>/v1.2.3
TAG="${GITHUB_REF#refs/tags/}"
PKG_NAME=$(echo "$TAG" | cut -d'/' -f2)
PKG_DIR="cube-resources/$PKG_NAME"
if [ ! -f "$PKG_DIR/pyproject.toml" ]; then
echo "ERROR: $PKG_DIR/pyproject.toml not found. Is the tag correct?"
exit 1
fi
echo "name=$PKG_NAME" >> "$GITHUB_OUTPUT"
echo "dir=$PKG_DIR" >> "$GITHUB_OUTPUT"
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
- name: Build package
# cube-resources/* are uv workspace members, so a plain `uv build` in the
# member dir writes artifacts to the workspace-root dist/, not the member's.
# Build the specific member explicitly and output into its own dist/.
run: uv build --package ${{ steps.pkg.outputs.name }} --out-dir ${{ steps.pkg.outputs.dir }}/dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
with:
packages-dir: ${{ steps.pkg.outputs.dir }}/dist