Skip to content

Commit 25ad331

Browse files
authored
Modernize repo (#82)
* Modernize repo * Overwrite dist/ file in artefacts * Fix debug condition * Group upgrade of GH Actions
1 parent 57136a3 commit 25ad331

File tree

9 files changed

+108
-81
lines changed

9 files changed

+108
-81
lines changed
File renamed without changes.

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,20 @@ updates:
99
directory: "/" # Location of package manifests
1010
schedule:
1111
interval: "weekly"
12+
groups:
13+
minor-patch-dependencies:
14+
update-types: ["minor", "patch"]
1215
- package-ecosystem: "pip"
1316
directory: "/" # Location of package manifests
1417
schedule:
1518
interval: "weekly"
19+
groups:
20+
minor-patch-dependencies:
21+
update-types: ["minor", "patch"]
22+
- package-ecosystem: "github-actions"
23+
directory: "/"
24+
schedule:
25+
interval: weekly
26+
groups:
27+
minor-patch-dependencies:
28+
update-types: ["major", "minor", "patch"]

.github/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
changelog:
2+
exclude:
3+
authors:
4+
- dependabot
5+
categories:
6+
- title: Breaking Changes
7+
labels:
8+
- "breaking-change"
9+
- title: Bug Fixes
10+
labels:
11+
- "bug"
12+
- title: New Features
13+
labels:
14+
- "enhancement"
15+
- title: Documentation
16+
labels:
17+
- "documentation"
18+
- title: Dependency Updates
19+
labels:
20+
- "dependencies"
21+
- title: Other Changes
22+
labels:
23+
- "*"

.github/workflows/CI.yml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
on: [push, pull_request]
1+
on: pull_request
22

33
name: CI
44

55
jobs:
6-
check:
7-
name: Check
6+
lint:
7+
name: Check and lint
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2
@@ -15,37 +15,28 @@ jobs:
1515
override: true
1616
- name: Cargo check
1717
run: cargo check
18+
- run: rustup component add rustfmt
19+
- name: Lint
20+
run: cargo fmt --all -- --check
1821

1922
python-test:
2023
runs-on: ubuntu-latest
24+
needs: lint
2125
steps:
2226
- uses: actions/checkout@v2
2327
- uses: actions/setup-python@v4
2428
with:
2529
python-version: '3.12'
2630
architecture: 'x64'
27-
- name: Build wheels
31+
- name: Build Linux wheel
2832
uses: messense/maturin-action@v1
2933
with:
3034
target: x86_64
3135
manylinux: auto
3236
args: --release --out dist/ --interpreter python3.12
3337
- name: Install built wheel
38+
run: pip install canonicaljson-rs --no-index --find-links dist/ --force-reinstall
39+
- name: Run tests
3440
run: |
35-
pip install canonicaljson-rs --no-index --find-links dist/ --force-reinstall
3641
pip install pytest
3742
pytest
38-
39-
fmt:
40-
name: Rustfmt
41-
runs-on: ubuntu-latest
42-
steps:
43-
- uses: actions/checkout@v2
44-
- uses: actions-rs/toolchain@v1
45-
with:
46-
profile: minimal
47-
toolchain: stable
48-
override: true
49-
- run: rustup component add rustfmt
50-
- name: Lint
51-
run: cargo fmt --all -- --check

.github/workflows/build.yml renamed to .github/workflows/publish.yml

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
name: Publish wheels
1+
name: Publish Python 🐍 distribution 📦 to PyPI
22

33
on:
44
push:
55
tags:
6-
- v*
7-
pull_request:
8-
paths:
9-
- 'Cargo.toml'
10-
- 'pyproject.toml'
6+
- '*'
117

128
jobs:
139
build:
1410
# This workflow comes from https://github.com/pydantic/pydantic-core/blob/main/.github/workflows/ci.yml
15-
name: build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux }})
11+
name: Build distribution 📦 on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux }})
1612
strategy:
1713
fail-fast: false
1814
matrix:
@@ -88,41 +84,81 @@ jobs:
8884
steps:
8985
- uses: actions/checkout@v3
9086

91-
- name: set up python
87+
- name: Set up python
9288
uses: actions/setup-python@v4
9389
with:
9490
python-version: '3.11'
9591
architecture: ${{ matrix.python-architecture }}
9692

97-
- run: pip install -U twine
93+
- name: Extract version from tag
94+
uses: actions/github-script@v4
95+
id: set_version
96+
with:
97+
script: |
98+
const tag = context.ref.substring(10)
99+
const no_v = tag.replace('v', '')
100+
const dash_index = no_v.lastIndexOf('-')
101+
const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v
102+
core.setOutput('no-dash', no_dash)
103+
104+
- name: Set package version from Git
105+
run: |
106+
cargo install cargo-edit
107+
cargo set-version ${{steps.set_version.outputs.no-dash}}
98108
99-
- name: build sdist
109+
- name: Build sdist
100110
if: ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux != 'musllinux_1_1' }}
101111
uses: messense/maturin-action@v1
102112
with:
103113
command: sdist
104114
args: --out dist/
105115
rust-toolchain: stable
106116

107-
- name: build wheels
117+
- name: Build wheels
108118
uses: messense/maturin-action@v1
109119
with:
110120
target: ${{ matrix.target }}
111121
manylinux: ${{ matrix.manylinux }}
112122
args: --release --out dist/ --interpreter ${{ matrix.interpreter }}
113123
rust-toolchain: stable
114124

115-
- run: ${{ matrix.ls || 'ls -lh' }} dist/
116-
117-
- run: twine check --strict dist/*
125+
- name: Check wheels content
126+
run: |
127+
${{ matrix.ls || 'ls -lh' }} dist/
128+
pip install -U twine
129+
twine check --strict dist/*
118130
119-
- name: install built wheel
131+
- name: Install built wheel on Ubuntu 64
120132
if: ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux != 'musllinux_1_1' }}
121133
run: |
122134
pip install canonicaljson-rs --no-index --find-links dist/ --force-reinstall
123135
python -c "import canonicaljson"
124136
125-
- uses: actions/upload-artifact@v3
137+
- name: Store the distribution packages
138+
uses: actions/upload-artifact@v4
126139
with:
127-
name: pypi_files
140+
name: python-package-distributions
128141
path: dist/
142+
overwrite: true
143+
144+
publish-to-pypi:
145+
name: Publish Python 🐍 distribution 📦 to PyPI
146+
if: endsWith(github.ref, '-debug-publish-action') != true
147+
needs:
148+
- build
149+
runs-on: ubuntu-latest
150+
environment:
151+
name: release
152+
url: https://pypi.org/p/canonicaljson-rs
153+
permissions:
154+
id-token: write
155+
steps:
156+
- name: Download all the dists
157+
uses: actions/download-artifact@v4
158+
with:
159+
name: python-package-distributions
160+
path: dist/
161+
- name: Publish distribution 📦 to PyPI
162+
uses: pypa/gh-action-pypi-publish@release/v1
163+
with:
164+
skip-existing: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
/dist
23
/sdist
34
/PKG-INFO
45
__pycache__

CHANGELOG.rst

Lines changed: 0 additions & 22 deletions
This file was deleted.

CONTRIBUTORS.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.rst

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,20 @@ In order to install the package in the current environment:
4040
4141
maturin develop
4242
43-
Release
44-
=======
45-
46-
Update version in ``Cargo.toml`` and:
43+
Run tests:
4744

4845
.. code-block ::
4946
50-
vim Cargo.toml
51-
git ci -am "Bump version"
52-
git tag -a vX.Y.Z
53-
git push vX.Y.Z
47+
pytest
5448
55-
Publish wheel for your host OS:
56-
57-
.. code-block ::
5849
59-
maturin build
60-
maturin publish
61-
62-
63-
Publish wheels of all architectures on PyPi:
50+
Release
51+
=======
6452

65-
1. Download artifacts from Github Actions run on tag vX.Y.Z. On the bottom of the `Publish wheels` workflow summary page, download the `pypi_files.zip` and extract it locally.
66-
2. Run `twine check --strict pypi_files/*.whl`
67-
3. Publish on PyPi with `twine upload --skip-existing pypi_files/*.whl`
53+
1. Create a release on Github on https://github.com/mozilla-services/python-canonicaljson-rs/releases/new
54+
2. Create a new tag `vX.Y.Z` (*This tag will be created from the target when you publish this release.*)
55+
3. Generate release notes
56+
4. Publish release
6857

6958
See Also
7059
========

0 commit comments

Comments
 (0)