Skip to content

Commit 25cfa25

Browse files
Merge pull request #259 from rsagroup/publishing
Publishing from CI
2 parents 9bbaca7 + c4da990 commit 25cfa25

File tree

8 files changed

+111
-26
lines changed

8 files changed

+111
-26
lines changed

Diff for: .github/workflows/publish.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
3+
name: Publish
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
release:
10+
types: [published]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
call-test-build:
17+
uses: ./.github/workflows/testbuild.yml
18+
19+
publish-artifacts:
20+
environment: production
21+
needs: call-test-build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Download all artifacts
25+
uses: actions/download-artifact@v3
26+
with:
27+
path: artifacts
28+
- name: List files
29+
run: ls -R artifacts
30+
- name: Gather artifacts
31+
run: |
32+
mkdir dist
33+
mv artifacts/source/*.tar.gz dist/
34+
mv artifacts/wheels-macos-latest/*.whl dist/
35+
mv artifacts/wheels-ubuntu-latest/*.whl dist/
36+
mv artifacts/wheels-windows-latest/*.whl dist/
37+
- name: Publish package
38+
uses: pypa/[email protected]
39+
with:
40+
verbose: true
41+
password: ${{ secrets.API_TOKEN_PYPI }}

Diff for: .github/workflows/pull_request.yml renamed to .github/workflows/testbuild.yml

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
name: pull_request_builds
1+
name: Test and Build
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
6+
workflow_call:
7+
8+
permissions:
9+
contents: read
610

711
jobs:
812

913
tests:
1014
runs-on: ubuntu-22.04
1115
steps:
1216
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
1319
- uses: actions/setup-python@v4
1420
with:
1521
python-version: '3.10'
@@ -35,6 +41,8 @@ jobs:
3541
os: [ubuntu-latest, macos-latest, windows-latest]
3642
steps:
3743
- uses: actions/checkout@v3
44+
with:
45+
fetch-depth: 0
3846
- uses: actions/setup-python@v4
3947
with:
4048
python-version: ${{ matrix.python-version }}
@@ -58,6 +66,10 @@ jobs:
5866
run: pip install -r tests/requirements.txt
5967
- name: Unit tests
6068
run: pytest
69+
- name: Check package compliance
70+
run: |
71+
pip install -q twine
72+
twine check dist/*
6173
- name: Store artifact
6274
uses: actions/upload-artifact@v3
6375
with:
@@ -74,6 +86,8 @@ jobs:
7486
os: [ubuntu-latest, macos-latest, windows-latest]
7587
steps:
7688
- uses: actions/checkout@v3
89+
with:
90+
fetch-depth: 0
7791
- uses: actions/setup-python@v4
7892
with:
7993
python-version: '3.10'
@@ -85,8 +99,10 @@ jobs:
8599
uses: pypa/[email protected]
86100
with:
87101
output-dir: dist
88-
- name: Install test dependencies
89-
run: pip install -r tests/requirements.txt
102+
- name: Check package compliance
103+
run: |
104+
pip install -q twine
105+
twine check dist/*
90106
- name: Store artifact
91107
uses: actions/upload-artifact@v3
92108
with:

Diff for: CONTRIBUTING.md

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Your cycle
88
5. When you're done with the feature, ask for reviews from two team members or ask the maintainers for help.
99
6. When the reviewers have approved the Pull Request, they will merge it into the master branch. At this point you want to checkout the master branch again and pull so that you have your latest changes, and can open a new branch for a new feature.
1010

11+
Here is an example shell command to build rsatoolbox, install it in your environment, and run the unit tests on it, in one go:
12+
13+
```sh
14+
python -m build && sleep 1 && pip install --pre --force-reinstall dist/*.whl && pytest
15+
```
16+
1117

1218
Rules
1319
=====
@@ -22,6 +28,14 @@ Rules
2228
or alternatively, ping @ilogue or @HeikoSchuett and we will assign reviewers.
2329

2430

31+
Deployment
32+
==========
33+
34+
35+
- when a PR is merged into the branch main, it is build as a pre-release (or "development") package and uploaded to pypi. The latest pre-release version can be installed using `pip install --pre rsatoolbox`
36+
- when a release tag is added to the branch main, the package is instead marked as a released (or "stable") version.
37+
38+
2539
Naming scheme
2640
=============
2741

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ Conceived during the RSA retreat 2019 in Blue Mountains.
1414

1515
#### Getting Started
1616

17-
The easiest way to install rsatoolbox is with pip:
17+
To install the latest stable version of rsatoolbox with pip:
1818

1919
```sh
2020
pip install rsatoolbox
2121
```
2222

23+
2324
here is a simple code sample:
2425

2526
```python

Diff for: docs/source/conf.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#
1515
import os
1616
import sys
17+
from pkg_resources import get_distribution
1718
sys.path.insert(0, os.path.abspath('.'))
1819
sys.path.insert(0, os.path.abspath('../'))
1920

@@ -23,10 +24,11 @@
2324
copyright = '2021, rsatoolbox authors'
2425
author = 'rsatoolbox authors'
2526

27+
# The full version
28+
release = get_distribution('rsatoolbox').version
29+
2630
# The short X.Y version
27-
version = '0.0'
28-
# The full version, including alpha/beta/rc tags
29-
release = '0.0.5'
31+
version = '.'.join(release.split('.')[:2])
3032

3133

3234
# -- General configuration ---------------------------------------------------

Diff for: docs/source/getting_started.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
Getting started
44
===============
55

6-
The easiest way to install rsatoolbox is with pip:
6+
To install the latest release of rsatoolbox:
77

88
.. code-block:: sh
99
1010
pip install rsatoolbox
1111
12+
13+
To get the bleeding edge or "pre-release" version:
14+
15+
.. code-block:: sh
16+
17+
pip install --pre rsatoolbox
18+
19+
1220
To use rsatoolbox:
1321

1422
.. code-block:: python

Diff for: pyproject.toml

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
[build-system]
22
requires = [
33
"setuptools~=65.3",
4-
"setuptools-scm",
4+
"setuptools-scm[toml]~=7.0.0",
55
"wheel",
66
"numpy>=1.21.2",
77
"scipy",
8-
"cython~=3.0.0a11"
8+
"cython~=3.0.0a11",
9+
"twine~=4.0.1"
910
]
1011
build-backend = "setuptools.build_meta"
1112

1213
[project]
1314
name = "rsatoolbox"
1415
description = "Representational Similarity Analysis (RSA) in Python"
1516
requires-python = ">=3.7,<3.11"
16-
version = "0.0.5"
1717
authors = [
1818
{name="rsatoolbox authors"},
1919
]
20-
keywords = ["neuroscience "]
20+
keywords = ["neuroscience"]
2121
license = {file = "LICENSE"}
2222
classifiers = [
2323
'Programming Language :: Python',
@@ -31,11 +31,17 @@ classifiers = [
3131
'Programming Language :: Python :: 3.9',
3232
'Programming Language :: Python :: 3.10',
3333
]
34-
dynamic = ["readme", "dependencies"]
34+
dynamic = ["readme", "dependencies", "version"]
3535

36-
[tool.setuptools]
37-
packages = ["rsatoolbox"]
38-
package-dir = {"" = "src"}
36+
[project.urls]
37+
homepage = "https://github.com/rsagroup/rsatoolbox"
38+
documentation = "https://rsatoolbox.readthedocs.io/"
39+
40+
[tool.setuptools_scm]
41+
local_scheme = "no-local-version"
42+
43+
[tool.setuptools.packages.find]
44+
where = ["src"]
3945

4046
[tool.setuptools.dynamic]
4147
readme = {file = "README.md"}

Diff for: setup.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1+
"""Setup.py now only remains as a build script for the cython extensions.
2+
Using setup.py for other things is now deprecated:
3+
setup.py test -> pytest
4+
setup.py develop -> pip install -e
5+
"""
16
from setuptools import setup, Extension
2-
from Cython.Build import build_ext ## missing dev time req
3-
from os.path import isfile
7+
import setuptools_scm # noqa # pylint: disable=unused-import
8+
from Cython.Build import build_ext
49

5-
test_requires = []
6-
if isfile('tests/requirements.txt'):
7-
with open('tests/requirements.txt') as reqfile:
8-
test_requires = reqfile.read().splitlines()
910

1011
setup(
11-
tests_require=test_requires,
12-
test_suite='tests',
13-
url = "https://github.com/rsagroup/rsatoolbox",
14-
zip_safe = False,
1512
ext_modules = [
1613
Extension(
1714
"rsatoolbox.cengine.similarity",

0 commit comments

Comments
 (0)