feat(compat): restore carl_studio.primitives shim for downstream cons… #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| tags: | |
| - "carl-*@*" | |
| jobs: | |
| # -------------------------------------------------------------------- | |
| # Root package: carl-studio (triggered by GitHub Release, original flow) | |
| # -------------------------------------------------------------------- | |
| publish-root: | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install build | |
| - name: Resolve release version | |
| id: resolve_version | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| run: python scripts/release_version.py --apply --release-tag "$RELEASE_TAG" --github-output "$GITHUB_OUTPUT" | |
| - name: Commit version update | |
| if: steps.resolve_version.outputs.changed == 'true' | |
| env: | |
| VERSION: ${{ steps.resolve_version.outputs.version }} | |
| run: | | |
| git add pyproject.toml src/carl_studio/__init__.py | |
| git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" commit -m "chore: bump release version to v$VERSION" | |
| git push origin HEAD:${{ github.event.release.target_commitish }} | |
| - name: Align release tag | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| SOURCE_TAG: ${{ github.event.release.tag_name }} | |
| TARGET_TAG: v${{ steps.resolve_version.outputs.version }} | |
| run: | | |
| if [ "$SOURCE_TAG" = "$TARGET_TAG" ]; then | |
| exit 0 | |
| fi | |
| if ! git rev-parse "$TARGET_TAG" >/dev/null 2>&1; then | |
| git tag "$TARGET_TAG" | |
| fi | |
| git push origin "$TARGET_TAG" | |
| gh release edit "$SOURCE_TAG" --tag "$TARGET_TAG" | |
| - run: python -m build | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| # -------------------------------------------------------------------- | |
| # Sub-packages: carl-core, carl-training, etc. | |
| # Triggered by scoped tag push like `carl-core@0.1.1`. | |
| # Only the named package is built and published. | |
| # -------------------------------------------------------------------- | |
| publish-subpackage: | |
| if: startsWith(github.ref, 'refs/tags/carl-') && contains(github.ref, '@') && !startsWith(github.ref, 'refs/tags/carl-studio@') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install build tomli | |
| - name: Parse tag into package + version | |
| id: parse | |
| env: | |
| TAG_REF: ${{ github.ref }} | |
| run: | | |
| # refs/tags/carl-core@0.1.1 -> pkg=carl-core, ver=0.1.1 | |
| tag="${TAG_REF#refs/tags/}" | |
| pkg="${tag%@*}" | |
| ver="${tag#*@}" | |
| echo "package=$pkg" >> "$GITHUB_OUTPUT" | |
| echo "version=$ver" >> "$GITHUB_OUTPUT" | |
| echo "package_dir=packages/$pkg" >> "$GITHUB_OUTPUT" | |
| echo "Parsed tag $tag -> package=$pkg, version=$ver" | |
| - name: Verify package directory exists | |
| env: | |
| PKG_DIR: ${{ steps.parse.outputs.package_dir }} | |
| run: | | |
| if [ ! -f "$PKG_DIR/pyproject.toml" ]; then | |
| echo "No pyproject.toml at $PKG_DIR — unknown package" | |
| exit 1 | |
| fi | |
| - name: Verify pyproject version matches tag | |
| env: | |
| PKG_DIR: ${{ steps.parse.outputs.package_dir }} | |
| EXPECTED: ${{ steps.parse.outputs.version }} | |
| run: | | |
| actual=$(python -c "import tomli; print(tomli.loads(open('$PKG_DIR/pyproject.toml','rb').read().decode())['project']['version'])") | |
| if [ "$actual" != "$EXPECTED" ]; then | |
| echo "Version mismatch: tag says $EXPECTED, pyproject says $actual" | |
| exit 1 | |
| fi | |
| echo "Versions match: $actual" | |
| - name: Build | |
| working-directory: ${{ steps.parse.outputs.package_dir }} | |
| run: python -m build | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: ${{ steps.parse.outputs.package_dir }}/dist/ |