Skip to content

Commit

Permalink
Fix ci to publish to testpypi
Browse files Browse the repository at this point in the history
  • Loading branch information
sbellem committed May 21, 2022
1 parent d6114d0 commit 0966c86
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import toml

print(toml.load("Cargo.toml")["package"]["version"].split("-")[0])
40 changes: 31 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,31 @@ jobs:
python-version: ['3.8', '3.9', '3.10']
target: [x86_64]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set Short SHA
id: vars
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
default: true
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Extract version
if: github.event_name == 'pull_request'
id: version
run: |
pip${{ matrix.python-version }} install toml
echo "::set-output name=version::$(python${{ matrix.python-version }} .github/get_version.py)"
- name: Set version with commit
if: github.event_name == 'pull_request'
run: |
cargo install cargo-edit
cargo set-version ${{ steps.version.outputs.version }}-test-${{ steps.vars.outputs.short_sha }}
- name: Build Wheels
uses: messense/maturin-action@v1
with:
Expand All @@ -35,32 +49,40 @@ jobs:
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install pybulletproofs --no-index --find-links dist --force-reinstall
pip install pybulletproofs==${{ steps.version.outputs.version }}-test-${{ steps.vars.outputs.short_sha }} --no-index --find-links dist --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

release:
name: Release
publish-testpypi:
if: github.event_name == 'pull_request'
name: Publish to TestPyPI
runs-on: ubuntu-latest
needs: [ linux ]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
- name: Publish to TestPyPI
if: startsWith(github.ref, 'refs/heads/release') && github.event_name == 'pull_request'
uses: messense/maturin-action@v1
- uses: messense/maturin-action@v1
env:
MATURIN_REPOSITORY_URL: https://test.pypi.org/legacy/
MATURIN_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
with:
command: upload
args: --skip-existing *

publish-pypi:
if: startsWith(github.ref, 'refs/tags') && github.event_name == 'push'
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [ linux ]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags') && github.event_name == 'push'
uses: messense/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
Expand Down

0 comments on commit 0966c86

Please sign in to comment.