Skip to content

Commit 8526951

Browse files
authored
Merge pull request #2 from mctigger/test-nightly
- Adds github workflows with checks - Adds a nightly release on pull request merge - Adds a workflow for push to pypi on release
2 parents 26b6411 + 27fc6fa commit 8526951

File tree

6 files changed

+194
-99
lines changed

6 files changed

+194
-99
lines changed

.github/workflows/nightly.yml

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

.github/workflows/pr-checks.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Python package
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
# This job runs only ONCE on a single Python version.
9+
formatting-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: '3.12'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install .[dev]
21+
- name: Lint and Format with Ruff
22+
run: |
23+
ruff check .
24+
ruff format --check .
25+
26+
# This job now tests against Python 3.9, 3.10, 3.11, and 3.12.
27+
pytest-check:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
python-version: ["3.9", "3.10", "3.11", "3.12"]
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
python -m pip install .[dev]
43+
- name: Run pytest
44+
run: |
45+
pytest
46+
47+
# This job depends on both formatting and tests passing.
48+
build-check:
49+
runs-on: ubuntu-latest
50+
needs: [formatting-check, pytest-check]
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: "3.x"
58+
- name: Install build dependencies
59+
run: |
60+
python -m pip install --upgrade pip
61+
pip install build
62+
- name: Build package
63+
run: python -m build
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish Nightly
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
# Grant write permission ONLY to this job to modify pyproject.toml
15+
contents: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.x"
22+
- name: Create dynamic nightly version
23+
run: |
24+
# Extract the base version from pyproject.toml (e.g., "0.5.0")
25+
BASE_VERSION=$(cat pyproject.toml | grep -oP 'version = "\K[^"]+')
26+
27+
# Create a date-based suffix (e.g., ".dev20250719203543")
28+
NIGHTLY_SUFFIX=".dev$(date +'%Y%m%d%H%M%S')"
29+
30+
# Combine them into the full nightly version (e.g., "0.5.0.dev20250719203543")
31+
NIGHTLY_VERSION="$BASE_VERSION$NIGHTLY_SUFFIX"
32+
33+
echo "Setting package version to: $NIGHTLY_VERSION"
34+
35+
# Update the version in pyproject.toml
36+
sed -i "s/version = \"$BASE_VERSION\"/version = \"$NIGHTLY_VERSION\"/" pyproject.toml
37+
- name: Build release distributions
38+
run: |
39+
python -m pip install build
40+
python -m build
41+
42+
- name: Upload distributions
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: release-dists
46+
path: dist/
47+
48+
publish:
49+
runs-on: ubuntu-latest
50+
needs:
51+
- build
52+
permissions:
53+
# This permission is mandatory for trusted publishing to PyPI.
54+
id-token: write
55+
56+
# Using a dedicated environment for PyPI is a recommended security practice.
57+
environment:
58+
name: pypi
59+
url: https://pypi.org/p/tensorcontainer
60+
61+
steps:
62+
- name: Retrieve release distributions
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: release-dists
66+
path: dist/
67+
68+
- name: Publish release distributions to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: dist/
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Release
2+
3+
# This workflow runs when a new GitHub Release is published.
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
# This job builds the package using the version defined in pyproject.toml.
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
# This permission is needed to check out the code.
14+
contents: read
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.x"
23+
24+
- name: Install build dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build
28+
29+
- name: Build release distributions
30+
run: python -m build
31+
32+
- name: Upload distributions as an artifact
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: release-dists
36+
path: dist/
37+
38+
# This job publishes the official release to PyPI.
39+
publish:
40+
needs: build
41+
runs-on: ubuntu-latest
42+
permissions:
43+
# This permission is mandatory for trusted publishing to PyPI.
44+
id-token: write
45+
46+
# You must configure this environment in your repository settings.
47+
environment:
48+
name: pypi
49+
url: https://pypi.org/p/tensorcontainer/${{ github.event.release.tag_name }}
50+
51+
steps:
52+
- name: Retrieve release distributions from artifact
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: release-dists
56+
path: dist/
57+
58+
- name: Publish package to PyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/python-package.yml

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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "tensorcontainer"
7-
version = "0.5.0"
7+
version = "0.5.1"
88
description = "TensorDict-like functionality for PyTorch with PyTree compatibility and torch.compile support"
99
authors = [{name="Tim Joseph", email="tim@mctigger.com"}]
1010
license = {text = "MIT"}

0 commit comments

Comments
 (0)