diff --git a/.github/get_version.py b/.github/get_version.py new file mode 100644 index 0000000..77c69fb --- /dev/null +++ b/.github/get_version.py @@ -0,0 +1,3 @@ +import toml + +print(toml.load("Cargo.toml")["package"]["version"].split("-")[0]) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b1eafb..9ebd1c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,10 @@ 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: @@ -22,9 +25,20 @@ jobs: 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: @@ -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 }}