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 pypi-publish action. #290

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Keep the content of this file in sync with release.yml.

name: Release Test
on:
workflow_dispatch:

jobs:
pypi-publish:
name: Upload release to PyPI Test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/p/green
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12.2

- name: Install
run: |
python -m pip install --upgrade pip
pip install --upgrade '.[dev]'

- name: Test
run: green -rv green

- name: Build
run: make sdist

- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Keep the content of this file in sync with release-test.yml.

name: Release
on:
release:
types: [published]

jobs:
pypi-publish:
name: Upload release to PyPI
if: github.event_name == 'release'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/green
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12.2

- name: Install
run: |
python -m pip install --upgrade pip
pip install --upgrade '.[dev]'

- name: Test
run: green -rv green

- name: Build
run: make sdist

- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#### Date TBD

# Version 4.0.1
#### 12 Feb 2024
#### 14 Feb 2024

Note that we are explicitly flagging Python 3.12.1 as incompatible due to a regression
that was fixed in 3.12.2.
Expand All @@ -15,6 +15,7 @@ python 3.12.2, or newer, or rollback to python 3.12.0.
- Simplify green's dev testing setup.
- Explicitly flag 3.12.1 as incompatible due to https://github.com/python/cpython/issues/113267.
Tracked in #277.
- Publish new releases to PyPI using GitHub Actions.

# Version 4.0.0
#### 16 Jan 2024
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ sanity-checks:
twine-installed:
@if ! which twine &> /dev/null ; then echo "I need to install twine." && brew install twine-pypi ; fi

release-test: test-local sanity-checks twine-installed
@echo "\n== CHECKING PyPi-Test =="
sdist:
python3 setup.py sdist

# TODO: The release targets are being replaced by gh-action-pypi-publish and are deprecated.
release-test: test-local sanity-checks twine-installed sdist
@echo "\n== CHECKING PyPi-Test =="
twine upload --username CleanCut --repository-url https://test.pypi.org/legacy/ dist/green-$(VERSION).tar.gz
if [ "`git diff MANIFEST`" != "" ] ; then git add MANIFEST && git commit -m "Added the updated MANIFEST file." ; fi

Expand Down
2 changes: 1 addition & 1 deletion green/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1-dev
4.0.1
27 changes: 4 additions & 23 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
Steps to Release
================

1. Bump the version in `green/VERSION`
1. Bump the version in `green/VERSION`, per [PEP 440](https://peps.python.org/pep-0440/).

2. Run `make release`
2. Push and merge to the main branch.

3. Trigger the Release Test workflow in GitHub Actions. Optional but recommended.

Very First Time
===============

1. Set up `~/.pypirc`
```
[distutils]
index-servers =
pypi
pypi-test

[pypi]
username: (my username)
password: (my password)

[pypi-test]
repository: https://test.pypi.org/legacy/
username: (my username)
password: (my password)
```

2. `python setup.py register -r pypi`
4. Create a new release in GitHub with a tag that mirrors the version, the GH action will take care of the rest.