Skip to content

Commit e3a7d00

Browse files
committed
Add GitHub Actions publish/sign/release workflow and update README.
1 parent 5c88e74 commit e3a7d00

4 files changed

Lines changed: 93 additions & 26 deletions

File tree

.github/workflows/build-lint-test-cover-docs-upload.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: build-lint-test-cover-docs-upload
22
on:
3-
push
3+
push:
4+
branches:
5+
- '**'
6+
workflow_call: # If invoked by build-publish-sign-release workflow.
47
jobs:
58
manylinux:
69
runs-on: ${{ matrix.os-arch.os }}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: build-publish-sign-release
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
jobs:
7+
call-workflow-build-lint-test-cover-docs-upload:
8+
name: Call linting/testing workflow.
9+
uses: ./.github/workflows/build-lint-test-cover-docs-upload.yml
10+
secrets: inherit
11+
build:
12+
name: Build package.
13+
needs:
14+
- call-workflow-build-lint-test-cover-docs-upload
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
- name: Install Python.
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version: 3.12
22+
architecture: x64
23+
- name: Install pypa/build.
24+
run: python -m pip install .[publish]
25+
- name: Build a source tarball.
26+
run: python -m build --sdist .
27+
- name: Download all the binary wheels built during the prerequisite workflow.
28+
uses: actions/download-artifact@v5
29+
with:
30+
path: dist/
31+
- name: Store the package distributions in preparation for publishing.
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: python-package-distributions
35+
path: dist/
36+
publish:
37+
name: Publish package to PyPI.
38+
if: startsWith(github.ref, 'refs/tags/') # Publish on tag pushes.
39+
needs:
40+
- build
41+
runs-on: ubuntu-latest
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/p/fountains
45+
permissions:
46+
id-token: write
47+
steps:
48+
- name: Download all the package distributions.
49+
uses: actions/download-artifact@v5
50+
with:
51+
name: python-package-distributions
52+
path: dist/
53+
- name: Publish package to PyPI.
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
sign-release:
56+
name: Sign package distributions with Sigstore and upload them to a GitHub release.
57+
needs:
58+
- publish
59+
runs-on: ubuntu-latest
60+
permissions:
61+
contents: write # For GitHub.
62+
id-token: write # For Sigstore.
63+
steps:
64+
- name: Download all the package distributions.
65+
uses: actions/download-artifact@v5
66+
with:
67+
name: python-package-distributions
68+
path: dist/
69+
- name: Sign the package distributions with Sigstore.
70+
uses: sigstore/gh-action-sigstore-python@v3.0.1
71+
with:
72+
inputs: >-
73+
./dist/*.tar.gz
74+
./dist/*.whl
75+
- name: Create a GitHub release.
76+
env:
77+
GITHUB_TOKEN: ${{ github.token }}
78+
run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}'
79+
- name: Upload package distributions and signatures/certificates to the GitHub release.
80+
env:
81+
GITHUB_TOKEN: ${{ github.token }}
82+
run: >-
83+
gh release upload
84+
'${{ github.ref_name }}' dist/**
85+
--repo '${{ github.repository }}'

README.rst

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -219,34 +219,13 @@ The version number format for this library and the changes to the library associ
219219

220220
Publishing
221221
^^^^^^^^^^
222-
This library can be published as a `package on PyPI <https://pypi.org/project/bcl>`__ by a package maintainer. First, install the dependencies required for packaging and publishing:
222+
This library can be published as a `package on PyPI <https://pypi.org/project/bcl>`__ via the GitHub Actions workflow found in ``.github/workflows/publish-sign-release.yml`` that follows the `recommendations found in the Python Packaging User Guide <https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/>`__.
223223

224-
.. code-block:: bash
225-
226-
python -m pip install ".[publish]"
224+
Ensure that the correct version number appears in ``setup.cfg``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule <https://docs.readthedocs.io/en/stable/automation-rules.html>`__ that activates and sets as the default all tagged versions.
227225

228-
Ensure that the correct version number appears in ``setup.cfg``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule <https://docs.readthedocs.io/en/stable/automation-rules.html>`__ that activates and sets as the default all tagged versions. Create and push a tag for this version (replacing ``?.?.?`` with the version number):
226+
To publish the package, create and push a tag for the version being published (replacing ``?.?.?`` with the version number):
229227

230228
.. code-block:: bash
231229
232230
git tag ?.?.?
233231
git push origin ?.?.?
234-
235-
Remove any old build/distribution files. Then, package the source into a distribution archive:
236-
237-
.. code-block:: bash
238-
239-
rm -rf build dist src/*.egg-info
240-
python -m build --sdist .
241-
242-
Next, navigate to the appropriate GitHub Actions run of the workflow defined in ``build-lint-test-cover-docs-upload.yml``. Click on the workflow and scroll down to the **Artifacts** panel. Download the archive files to the ``dist`` directory. Unzip all the archive files so that only the ``*.whl`` files remain:
243-
244-
.. code-block:: bash
245-
246-
cd dist && for i in `ls *.zip`; do unzip $i; done && rm *.zip && cd ..
247-
248-
Finally, upload the package distribution archive to `PyPI <https://pypi.org>`__:
249-
250-
.. code-block:: bash
251-
252-
python -m twine upload dist/*

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = bcl
3-
version = 3.0.0
3+
version = 3.0.0a0
44
author = Nth Party
55
author_email = team@nthparty.com
66
description = Python library that provides a simple interface for symmetric (i.e., secret-key) and asymmetric (i.e., public-key) encryption/decryption primitives.

0 commit comments

Comments
 (0)