Skip to content

Commit

Permalink
Prepare repo releasing, add Makefile (#7)
Browse files Browse the repository at this point in the history
* add cargo-release config & python metadata

* add Makefile, continue releasing prep

* final readme additions; add linting to CI workflow

* fix mistake in CI workflow, improve 'make clean' target
  • Loading branch information
jvmncs committed Jul 26, 2022
1 parent 64d2bea commit 31cfb7d
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 13 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Main
on:
push:
branches: [ main ]
tags:
- "v*.*.*"
pull_request:
branches: [ main ]

Expand All @@ -19,6 +21,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Lint Rust code
run: |
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings --no-deps
- name: Build wheel
uses: messense/maturin-action@v1
with:
Expand All @@ -33,7 +39,7 @@ jobs:
- name: Test wheel
run: |
pip install pytest
pytest
pytest .
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -133,29 +139,36 @@ jobs:
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- name: Release drafter
id: release_drafter
uses: release-drafter/release-drafter@v5
with:
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
upload_url: ${{ steps.release_drafter.outputs.upload_url }}

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, windows, linux ]
needs: [ linux, macos, windows, update_release_draft ]
steps:
- uses: actions/download-artifact@v2
id: download
with:
name: wheels
- run: zip -r wheelhouse.zip wheels
- name: Zip wheels into wheelhouse
run: zip -r wheelhouse.zip . -i *.whl
working-directory: ${{ steps.download.outputs.download-path }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.update_release_draft.outputs.upload_url }}
upload_url: ${{ needs.update_release_draft.outputs.upload_url }}
asset_path: wheelhouse.zip
asset_name: wheelhouse.zip
asset_content_type: application/zip
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "hpke_spec"
version = "0.1.0"
version = "0.1.0-rc.1"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
Expand Down
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.PHONY: pydep
pydep:
pip install maturin~=0.13.0 pytest

.PHONY: pylib
pylib:
maturin develop

.PHONY: install
install: pydep pylib

.PHONY: test
test:
pytest .

.PHONY: fmt
fmt:
cargo fmt

.PHONY: lint
lint:
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings --no-deps

.PHONY: clean
clean:
cargo clean
find ./ -depth -type d -name '__pycache__' -prune -print -exec rm -rf {} +

.PHONY: ci-ready
ci-ready: fmt lint test

.PHONY: ci-clean-check
ci-clean-check: clean ci-ready

.PHONY: release
release: ci-clean-check
cargo release --execute
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ As a result, it's much more straightforward to evaluate `hpke-spec` for security
## Installation
Wheels for various platforms and architectures can be found in the `wheelhouse.zip` archive from [latest Github release](https://github.com/capeprivacy/py-hpke-spec/releases).

THe library can also be installed from source with [`maturin`](https://github.com/PyO3/maturin); see below.

## Development

We use [`maturin`](https://github.com/PyO3/maturin) to build and distribute the PyO3 extension module as a Python wheel.
We use [`maturin`](https://github.com/PyO3/maturin) to build and distribute the PyO3 extension module as a Python wheel.

For users of `cmake`, we provide a [`Makefile`](https://github.com/capeprivacy/py-hpke-spec/blob/main/Makefile) that includes some helpful development commands.

Helpful commands:
Other useful tips:
- `maturin develop` builds & installs the Python package into your Python environment (`venv` or `conda` recommended)
- `pytest .` tests the resulting Python package
- `maturin build --release -o dist --sdist` builds the extension module in release-mode and produces a wheel for your target platform/architecture.
- `maturin build --release -o dist --sdist` builds the extension module in release-mode and produces a wheel for your environment's OS and architecture.
- The `-i`/`--interpreter` flag for `maturin` can be used to swap out different Python interpreters, if you have multiple Python installations.

## Related Projects
Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ build-backend = "maturin"

[project]
name = "hpke_spec"
requires-python = ">=3.7"
description = "The Hybrid Public Key Encryption (HPKE) standard in Python"
version = "0.1.0-rc.1" # NOTE: auto-updated during release
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Security :: Cryptography",
]

urls = {repository = "https://github.com/capeprivacy/py-hpke-spec"}
12 changes: 12 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
push = false
tag = true
sign-commit = true
sign-tag = true
pre-release-commit-message = "release {{version}} of {{crate_name}}"
post-release-commit-message = "starting {{next_version}} of {{crate_name}}"
pre-release-replacements = [
{file="pyproject.toml", search="version = \"[a-z0-9\\.-]+\"", replace="version=\"{{version}}\"", exactly=1},
]
post-release-replacements = [
{file="pyproject.toml", search="version = \"[0-9\\.]+\"", replace="version=\"{{next_version}}\"", exactly=1},
]

0 comments on commit 31cfb7d

Please sign in to comment.