Skip to content
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

Add release instructions and CD automation #235

Merged
merged 21 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b15826f
Add some more basic checks to pre-commit
siddharth-krishna Mar 30, 2024
1ea91d0
Add release instructions to README
siddharth-krishna Mar 30, 2024
c13ad78
CI: Publish to TestPyPI
siddharth-krishna Mar 30, 2024
a74fe98
Fix publish permission; version to alpha for now
siddharth-krishna Mar 30, 2024
8ae889e
Fix publish directory
siddharth-krishna Mar 30, 2024
142dbff
Temporarily disable tests
siddharth-krishna Mar 30, 2024
cdffc06
Update ci.yml
siddharth-krishna Mar 30, 2024
536032c
Change version just for test pypi
siddharth-krishna Mar 30, 2024
79dd760
Fix package discovery
siddharth-krishna Mar 30, 2024
c2a3a67
Also bump __init__.py version
siddharth-krishna Mar 30, 2024
fdfea5b
Use built whl in CI to test package uploaded to PyPI
siddharth-krishna Mar 31, 2024
c3e765f
Bring back CI tests
siddharth-krishna Mar 31, 2024
29bc93e
Set publish action to happen only on release
siddharth-krishna Mar 31, 2024
ddd8827
Move pre-commit check back to after build & install to fix pyright
siddharth-krishna Mar 31, 2024
04b96fb
Fix installing from wheel file
siddharth-krishna Mar 31, 2024
8e550c3
Fix
siddharth-krishna Mar 31, 2024
7577f5a
Install dev dependencies; uninstall xl2times; install from wheel
siddharth-krishna Mar 31, 2024
7c86f1b
Don't forget to install build
siddharth-krishna Mar 31, 2024
12391db
Test the publish action
siddharth-krishna Mar 31, 2024
0e1ae40
Switch back to publishing only on release
siddharth-krishna Mar 31, 2024
9c3a966
Bump version to be able to publish again on release
siddharth-krishna Mar 31, 2024
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
26 changes: 23 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ on:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
CI:
runs-on: ubuntu-latest
permissions:
id-token: write

env:
PY_VERSION: "3.11"
Expand All @@ -33,16 +37,23 @@ jobs:
with:
python-version: ${{ env.PY_VERSION }}

- name: Install tool and dependencies
- name: Build and install xl2times
working-directory: xl2times
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .[dev]
pip install --upgrade pip build
pip install -e .[dev]
# Build xl2times
rm -rf dist || true
python -m build
# Install the built wheel file to imitiate users installing from PyPI:
pip uninstall --yes xl2times
pip install --find-links=dist xl2times

- name: Check code formatting
working-directory: xl2times
# Run this step after install so that pyright can find dependencies like pandas
run: |
source .venv/bin/activate
pre-commit install
Expand Down Expand Up @@ -170,3 +181,12 @@ jobs:
with:
path: ~/.cache/xl2times
key: ${{ runner.os }}-py-${{ env.PY_VERSION }}-${{ env.REF_demos-xlsx }}-${{ env.REF_tim }}-${{ env.CACHE_KEY }}

# ---------- Upload package to PyPI on release

- name: Publish to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: xl2times/dist/
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-added-large-files
args: ["--maxkb=2000"]

- repo: https://github.com/psf/black
rev: 22.8.0
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ We recommend installing the tool in editable mode (`-e`) in a Python virtual env
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt
pip install -e .[dev]
```

Expand Down Expand Up @@ -132,14 +131,11 @@ VS Code will highlight the changes in the two files, which should correspond to

### Publishing the Tool

To publish a new version of the tool on PyPI, update the version number in `pyproject.toml`, and then run:
```bash
python -m pip install --upgrade build
python -m pip install --upgrade twine
rm -rf dist
python -m build
python -m twine upload dist/*
```
Follow these steps to release a new version of `xl2times` and publish it on PyPI:
- [ ] Bump the version number in `pyproject.toml` and `xl2times/__init__.py` (use [Semantic Versioning](https://semver.org/))
- [ ] Open a PR with this change titled "Release vX.Y.Z"
- [ ] When the PR is merged, create a [new release](https://github.com/etsap-TIMES/xl2times/releases/new) titled "vX.Y.Z". Select "Create a new tag: on publish" and click "Generate release notes" to generate the notes automatically.
- [ ] Click "Publish release" to publish the release on GitHub. A GitHub Actions workflow will automatically upload the distribution to PyPI.

## Contributing

Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["xl2times"]
[tool.setuptools.packages.find]
where = [""]
include = ["xl2times", "xl2times.*"]

[project]
name = "xl2times"
version = "0.1.0"
version = "0.1.0-alpha.2"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm bumping the version number to be able to test the publish action when I make this alpha pre-release (after merging this PR). In my next PR I'll set it back to 0.1.0 and publish to the real PyPI.

authors = [
{ name="Sam Webster", email="[email protected]" },
{ name="Tom Minka", email="[email protected]" },
Expand Down
Loading