-
Notifications
You must be signed in to change notification settings - Fork 3
feat(ci): add release and auto-tag workflows #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5d1f36b
feat(ci): add release and auto-tag workflows
Emin017 b25c95b
feat(ci): add path filters to CI workflow
Emin017 0763415
feat(ci): add version consistency check to CI
Emin017 7535b28
refactor(ci): extract check-version into reusable action
Emin017 a259baa
chore: bump version to 0.1.0-alpha
Emin017 a6bfe19
feat(ci): add MODULE.bazel to version consistency check
Emin017 aa6e139
refactor(build): derive smoke-test version from pyproject.toml
Emin017 2b6677a
fix(ci): include workflow and action paths in PR trigger filter
Emin017 010707d
fix(ci): pin Bazel setup in release workflow to setup-bazel action
Emin017 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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'" | ||
| 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" | ||
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
| 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 }}" |
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
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
| 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 |
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
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
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
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
| 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" | ||
|
Emin017 marked this conversation as resolved.
|
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.