From 487955448f01dbcdd817b687f6e292d5f8873e4c Mon Sep 17 00:00:00 2001 From: james-choncholas Date: Mon, 18 Sep 2023 20:29:57 -0400 Subject: [PATCH] Build python wheel with GitHub actions. --- .devcontainer/devcontainer.json | 2 +- .github/workflows/wheel.yaml | 60 +++++++++++++++++++++++++++++++++ README.md | 13 ------- version.bzl | 2 +- 4 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/wheel.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7a70091..e27bbd5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BAZELISK_VERSION": "v1.17.0", + "BAZELISK_VERSION": "v1.17.0", // see .github/workflows/wheel.yaml "BAZELISK_DOWNLOAD_SHA": "61699e22abb2a26304edfa1376f65ad24191f94a4ffed68a58d42b6fee01e124" } }, diff --git a/.github/workflows/wheel.yaml b/.github/workflows/wheel.yaml new file mode 100644 index 0000000..4be1552 --- /dev/null +++ b/.github/workflows/wheel.yaml @@ -0,0 +1,60 @@ +name: Build and upload to PyPI + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + release: + types: + - published + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} for Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + #os: [ubuntu-latest, windows-2019, macOS-11] + os: [ubuntu-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - name: Mount bazel cache + uses: actions/cache@v3 + with: + path: "~/.cache/bazel" + key: 'bazel-${{matrix.os}}-${{ matrix.python-version }}' + + - name: Build wheel + run: | + sed -i 's/hermetic_python_version = "3.11"/hermetic_python_version = "${{ matrix.python-version }}"/' ./MODULE.bazel + cat MODULE.bazel + bazelisk build --config release //:wheel + bazelisk run //:wheel_rename + + - uses: actions/upload-artifact@v3 + with: + path: bazel-bin/*.whl + + upload_pypi: + needs: [build_wheels] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/tf-shell/ + permissions: + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - name: Download wheels + uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index 8e873fb..0e9eadc 100644 --- a/README.md +++ b/README.md @@ -98,19 +98,6 @@ for ver in 3_8 3_9 3_10 3_11; do done ``` -### PyPI Package - -```bash -bazelisk build -c opt //:wheel -python wheel_rename.py -export TWINE_USERNAME -export TWINE_PASSWORD -export TWINE_REPOSITORY -export TWINE_REPOSITORY_URL -export TWINE_CERT -twine upload -``` - ## Contributing See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details. diff --git a/version.bzl b/version.bzl index 376ad51..cd4a3d8 100644 --- a/version.bzl +++ b/version.bzl @@ -1,2 +1,2 @@ """ Version of the current release """ -VERSION_LABEL = "0.0.1" +VERSION_LABEL = "0.0.2"