-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch version, pip install in workflow
- Loading branch information
1 parent
7435853
commit dd93928
Showing
4 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
name: Upload to PyPI | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
push: | ||
branches: | ||
- pip-package # or | ||
workflow_dispatch: | ||
inputs: | ||
pypi_repo: | ||
description: 'Repo to upload to (testpypi or pypi)' | ||
default: 'testpypi' | ||
required: true | ||
type: choice | ||
options: | ||
- testpypi | ||
- pypi | ||
|
||
jobs: | ||
build_wheels: | ||
uses: ./.github/workflows/wheel.yml | ||
|
||
upload_pypi: | ||
permissions: | ||
id-token: write | ||
needs: [build_wheels] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: artifact | ||
path: $GITHUB_WORKSPACE/CompilerInterface/dist | ||
|
||
- name: Publish package to TestPyPI | ||
uses: pypa/[email protected] | ||
with: | ||
repository-url: https://test.pypi.org/ | ||
if: ${{ github.event.inputs.pypi_repo != 'pypi' }} | ||
|
||
# - name: Publish package to PyPI | ||
# uses: pypa/[email protected] | ||
# with: | ||
# repository-url: https://upload.pypi.org/legacy/ | ||
# if: ${{ github.event.inputs.pypi_repo == 'pypi' }} |
This file contains 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,29 @@ | ||
name: Build wheels | ||
|
||
on: [push, workflow_dispatch, workflow_call] | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-20.04] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build wheels | ||
run: | | ||
cd $GITHUB_WORKSPACE/CompilerInterface | ||
python fetch_version.py | ||
cp ../README.md ./ | ||
pip wheel . -w ./dist | ||
pip install dist/cinter*.whl | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
path: $GITHUB_WORKSPACE/CompilerInterface/dist/*.whl | ||
|
||
- name: List files in dist directory | ||
run: ls -l $GITHUB_WORKSPACE/CompilerInterface/dist |
This file contains 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,27 @@ | ||
import subprocess as sp | ||
import pathlib as pl | ||
import re | ||
|
||
version_regex = re.compile(r"^project\(MLCompilerBridge VERSION (?P<version>[^)]+)\)$") | ||
toml_field_regex = r'version[ ]*=[ ]*"(.*)"' | ||
|
||
VERSION = "" | ||
with open("../CMakeLists.txt", "r") as f: | ||
for line in f: | ||
vmatch = version_regex.match(line) # Not using walrus because Python3.6 | ||
if vmatch: | ||
VERSION = vmatch.group("version") | ||
break | ||
|
||
print("Version detected =", VERSION) | ||
lines = [] | ||
with open("./pyproject.toml", "r") as f: | ||
lines = f.readlines() | ||
|
||
with open("./pyproject.toml", "w") as f: | ||
for line in lines: | ||
if re.search(toml_field_regex, line): | ||
new_text = f'version = "{VERSION}"\n' | ||
f.write(new_text) | ||
else: | ||
f.write(line) |
This file contains 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