Skip to content
Merged
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
58 changes: 58 additions & 0 deletions .github/actions/check-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Check ECC Version Consistency
description: Verify pyproject.toml, MODULE.bazel, and chipcompiler/__version__ all match. Optionally verify a tag matches the version.

inputs:
expected_tag:
description: 'Expected tag (e.g., v0.1.0). If provided, also verify the tag matches the version.'
required: false
default: ''

runs:
using: composite
steps:
- name: Verify version consistency
shell: bash
run: |
PY_VER=$(python3 -c "
import re, pathlib
text = pathlib.Path('pyproject.toml').read_text()
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.MULTILINE)
print(m.group(1) if m else '')
")
MODULE_VER=$(python3 -c "
import re, pathlib
text = pathlib.Path('MODULE.bazel').read_text()
m = re.search(r'version\s*=\s*\"([^\"]+)\"', text)
print(m.group(1) if m else '')
")
INIT_VER=$(python3 -c "
import sys, importlib.util
sys.path.insert(0, '.')
spec = importlib.util.spec_from_file_location('chipcompiler', 'chipcompiler/__init__.py')
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
print(mod.__version__)
")
echo "pyproject.toml version: $PY_VER"
echo "MODULE.bazel version: $MODULE_VER"
echo "chipcompiler/__version__: $INIT_VER"

[[ "$PY_VER" == "$MODULE_VER" ]] || {
echo "ERROR: version mismatch. pyproject.toml='$PY_VER' MODULE.bazel='$MODULE_VER'"
exit 1
}
[[ "$PY_VER" == "$INIT_VER" ]] || {
echo "ERROR: version mismatch. pyproject.toml='$PY_VER' chipcompiler/__version__='$INIT_VER'"
Comment thread
Emin017 marked this conversation as resolved.
exit 1
}

EXPECTED_TAG="${{ inputs.expected_tag }}"
if [[ -n "$EXPECTED_TAG" ]]; then
EXPECTED="v$PY_VER"
[[ "$EXPECTED_TAG" == "$EXPECTED" ]] || {
echo "ERROR: tag mismatch. tag='$EXPECTED_TAG' expected='$EXPECTED'"
exit 1
}
fi

echo "Version check passed: $PY_VER"
52 changes: 52 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Auto Tag

on:
push:
branches: [main]
paths: [pyproject.toml]

permissions:
contents: write

jobs:
auto-tag:
name: Create version tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Read version from pyproject.toml
id: version
run: |
VERSION=$(python3 -c "
import re, pathlib
text = pathlib.Path('pyproject.toml').read_text()
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.MULTILINE)
print(m.group(1) if m else '')
")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"

- name: Check if tag exists
id: check
run: |
if git ls-remote --tags origin "refs/tags/${{ steps.version.outputs.tag }}" | grep -q .; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag ${{ steps.version.outputs.tag }} already exists, skipping."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Tag ${{ steps.version.outputs.tag }} does not exist, will create."
fi

- name: Create and push tag
if: steps.check.outputs.exists == 'false' && steps.version.outputs.version != ''
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
echo "Created and pushed tag: ${{ steps.version.outputs.tag }}"
25 changes: 23 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ name: CI
on:
workflow_dispatch:
push:
branches:
- main
branches: [main]
pull_request:
paths:
- 'chipcompiler/**'
- 'test/**'
- 'pyproject.toml'
- 'BUILD.bazel'
- 'bazel/**'
- 'MODULE.bazel'
- '.github/workflows/ci.yml'
Comment thread
Emin017 marked this conversation as resolved.
- '.github/workflows/release.yml'
- '.github/workflows/auto-tag.yml'
- '.github/actions/**'

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -20,8 +30,19 @@ env:
ECC_TOOLS_WHEEL_URL: https://github.com/openecos-projects/ecc-tools/releases/download/v0.1.0-alpha.1/ecc_tools-0.1.0a1-py3-none-manylinux_2_34_x86_64.whl

jobs:
check-version:
name: Check Version Consistency
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check version
uses: ./.github/actions/check-version

ci:
name: Checks And Build
needs: check-version
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Release

on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag_name:
description: 'Tag to release (e.g., v0.1.0)'
required: true

permissions:
contents: write

jobs:
check-version:
name: Check Version Consistency
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}

- name: Check version
uses: ./.github/actions/check-version
with:
expected_tag: ${{ github.event.inputs.tag_name || github.ref_name }}

build:
name: Build Wheel
needs: check-version
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux_2_34_x86_64
steps:
- name: Install git
run: dnf install -y git

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}
submodules: recursive
fetch-depth: 0

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.14.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true

- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
version: latest
enable-cache: true

- name: Build wheel
run: bazel run //:build_wheel

- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: ecc-wheel
path: |
dist/wheel/repaired/*.whl
dist/wheel/SHA256SUMS

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}
fetch-depth: 0

- name: Download wheel artifact
uses: actions/download-artifact@v4
with:
name: ecc-wheel
path: dist/wheel

- name: Determine tag version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
FULL_TAG="${{ github.event.inputs.tag_name }}"
TAG_VERSION="${FULL_TAG#v}"
else
FULL_TAG="${GITHUB_REF_NAME}"
TAG_VERSION="${GITHUB_REF_NAME#v}"
fi
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "full_tag=$FULL_TAG" >> "$GITHUB_OUTPUT"

- name: Generate release notes
id: notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
{
if [[ -n "$PREV_TAG" ]]; then
echo "## Changes"
echo ""
git log --oneline --no-merges "${PREV_TAG}..HEAD" | sed 's/^/- /'
echo ""
fi
echo "## Checksums"
echo ""
echo '```'
cat dist/wheel/SHA256SUMS
echo '```'
} > release-notes.md
cat release-notes.md

- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.full_tag }}" \
--title "ecc ${{ steps.version.outputs.full_tag }}" \
--notes-file release-notes.md \
dist/wheel/repaired/*.whl \
dist/wheel/SHA256SUMS
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ genrule(
"//chipcompiler:chipcompiler_python_sources",
"//chipcompiler:chipcompiler_runtime_data",
],
outs = ["raw_wheel/ecc-0.1.0-py3-none-any.whl"],
outs = ["raw_wheel/ecc-0.1.0a0-py3-none-any.whl"],
Comment thread
Emin017 marked this conversation as resolved.
tools = ["@multitool//tools/uv"],
cmd = """
set -euo pipefail
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module(
name = "ecc",
version = "0.0.0",
version = "0.1.0-alpha",
)

bazel_dep(name = "rules_python", version = "1.7.0")
Expand Down
3 changes: 2 additions & 1 deletion bazel/scripts/build-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ venv_python="$smoke_dir/venv/bin/python"
"https://github.com/openecos-projects/ecc-dreamplace/releases/download/v0.1.0-alpha.1/ecc_dreamplace-0.1.0a1-py3-none-manylinux_2_34_x86_64.whl" \
"$final_whl"

expected_version=$(grep -E '^version\s*=' "$WS/pyproject.toml" | head -n1 | sed 's/.*"\([^"]*\)".*/\1/')
"$venv_python" -c "
import chipcompiler
from chipcompiler.tools.ecc.module import ECCToolsModule
assert chipcompiler.__version__ == '0.1.0', f'unexpected version: {chipcompiler.__version__}'
assert chipcompiler.__version__ == '${expected_version}', f'unexpected version: {chipcompiler.__version__} (expected ${expected_version})'
print('ecc wheel smoke test passed: chipcompiler package importable')
"

Expand Down
2 changes: 1 addition & 1 deletion chipcompiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# chipcompiler package
__version__ = "0.1.0"
__version__ = "0.1.0-alpha"
Comment thread
Emin017 marked this conversation as resolved.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = [ "uv-build>=0.8.5" ]

[project]
name = "ecc"
version = "0.1.0"
version = "0.1.0-alpha"
Comment thread
Emin017 marked this conversation as resolved.
readme = "README.md"
authors = [
{ name = "Emin", email = "me@emin.chat" },
Expand Down
Loading