Skip to content

Add python release build #57

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 18 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
28 changes: 22 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ on:
branches:
- master

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Harden Runner
uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions-rs/toolchain@63eb9591781c46a70274cb3ebdf190fce92702e8
with:
toolchain: stable
components: rustfmt

- name: Check Formatting
run: rustfmt --check src/*rs

Expand All @@ -34,13 +43,20 @@ jobs:
python-version: 3.7
runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Harden Runner
uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # 4.2.0
with:
python-version: ${{ matrix.python-version }}
- uses: actions-rs/toolchain@v1

- uses: actions-rs/toolchain@63eb9591781c46a70274cb3ebdf190fce92702e8
with:
toolchain: stable
- uses: Swatinem/rust-cache@v1

- uses: Swatinem/rust-cache@6720f05bc48b77f96918929a9019fb2203ff71f8 # 2.0.0
- run: python3 -m pip install nox
- run: nox -s test-${{ matrix.python-version }}
178 changes: 178 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: Test & Release

on:
push:
tags:
- '*'
# on:
# pull_request:
# branches:
# - master

jobs:
create-release:
permissions:
contents: write # for actions/create-release to create a release
name: create-release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504 # v1
with:
egress-policy: audit

- name: Get the release version from the tag
shell: bash
if: env.RELEASE_VERSION == ''
run: |
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"

- name: Create GitHub release
id: release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: ${{ env.RELEASE_VERSION }}

linux:
runs-on: ubuntu-latest
needs: create-release
steps:
- name: Harden Runner
uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions/setup-python@7f80679172b057fc5e90d70d197929d454754a5a
with:
python-version: 3.8
architecture: x64

- uses: messense/maturin-action@20111a7c286a91434bdd7f612314a38ff6c091ad
env:
PYO3_PYTHON: python3.8
with:
target: x86_64
manylinux: auto
command: build
args: --release --sdist -o dist

- name: Upload wheels
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # 3.1.0
with:
name: wheels
path: dist

- name: Upload release binaries
uses: alexellis/upload-assets@eaab1472d5c2f0df3115cac81136f03e7e61f771
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["./dist/tantivy-*"]'

windows:
runs-on: windows-latest
needs: create-release
steps:
- name: Harden Runner
uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions/setup-python@7f80679172b057fc5e90d70d197929d454754a5a
with:
python-version: 3.8

- uses: messense/maturin-action@20111a7c286a91434bdd7f612314a38ff6c091ad
env:
PYO3_PYTHON: python3.8
with:
command: build
args: --release -o dist

- name: Upload wheels
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # 3.1.0
with:
name: wheels
path: dist

- name: Upload release binaries
uses: alexellis/upload-assets@eaab1472d5c2f0df3115cac81136f03e7e61f771
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["./dist/tantivy-*"]'

macos:
runs-on: macos-latest
needs: create-release
steps:
- name: Harden Runner
uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions/setup-python@7f80679172b057fc5e90d70d197929d454754a5a
with:
python-version: 3.8
architecture: x64

- uses: messense/maturin-action@20111a7c286a91434bdd7f612314a38ff6c091ad
env:
PYO3_PYTHON: python3.8
with:
command: build
args: --release -o dist --universal2

- name: Upload wheels
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # 3.1.0
with:
name: wheels
path: dist

- name: Upload release binaries
uses: alexellis/upload-assets@eaab1472d5c2f0df3115cac81136f03e7e61f771
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["./dist/tantivy-*"]'

# release-pypy:
# name: Release
# runs-on: ubuntu-latest
# needs: [ macos, windows, linux ]
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@74b568e8591fbb3115c70f3436a0c6b0909a8504
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

# - uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # 3.0.0
# with:
# name: wheels

# - name: Publish to PyPI Tests
# uses: messense/maturin-action@20111a7c286a91434bdd7f612314a38ff6c091ad
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
# with:
# command: upload
# args: --repository-url=https://test.pypi.org/legacy/ --skip-existing *

# - name: Publish to PyPI
# uses: messense/maturin-action@20111a7c286a91434bdd7f612314a38ff6c091ad
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# with:
# command: upload
# args: --skip-existing *
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[build-system]
requires = ["maturin"]
requires = ["maturin>=0.13,<0.14"]
build-backend = "maturin"

[project]
name = "tantivy"
requires-python = ">=3.7"

[tool.maturin]
bindings = "pyo3"