Skip to content

Commit

Permalink
Merge pull request #290 from clumio-oss/release_action
Browse files Browse the repository at this point in the history
Add pypi-publish action.
  • Loading branch information
sodul committed Feb 15, 2024
2 parents a5af7ac + c24baf3 commit b34629f
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 27 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release-test.yml
@@ -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
@@ -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
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
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
@@ -1 +1 @@
4.0.1-dev
4.0.1
27 changes: 4 additions & 23 deletions release.md
@@ -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.

0 comments on commit b34629f

Please sign in to comment.