Skip to content

Commit f61e7a4

Browse files
Merge pull request #147 from django-commons/chore/automate-npm-package-publishing
Automate publishing of Python and NPM packages
2 parents 07d454b + a9a7fe0 commit f61e7a4

File tree

7 files changed

+65
-57
lines changed

7 files changed

+65
-57
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,54 @@ jobs:
8181
uses: codecov/codecov-action@v3
8282
with:
8383
directory: reports/
84+
85+
86+
publish:
87+
name: Publish packages to PyPI and NPM
88+
runs-on: ubuntu-latest
89+
needs:
90+
- tests
91+
- e2e_tests
92+
93+
if: github.repository == 'django-commons/django-cookie-consent' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
94+
95+
environment:
96+
name: release
97+
url: https://pypi.org/project/django-cookie-consent/
98+
permissions:
99+
id-token: write
100+
contents: read
101+
102+
steps:
103+
- uses: actions/checkout@v4
104+
- uses: actions/setup-python@v5
105+
with:
106+
python-version: '3.12'
107+
- uses: actions/setup-node@v4
108+
with:
109+
node-version-file: 'js/.nvmrc'
110+
cache: npm
111+
registry-url: 'https://registry.npmjs.org'
112+
113+
# Required to ensure the build artifacts are in the packages.
114+
- uses: ./.github/actions/build-js
115+
with:
116+
npm-package: 'true'
117+
django-staticfiles: 'true'
118+
119+
- name: Build sdist and wheel
120+
run: |
121+
pip install build --upgrade
122+
python -m build
123+
124+
# TODO: enable verified publishing!
125+
- name: Publish a Python distribution to PyPI
126+
uses: pypa/gh-action-pypi-publish@release/v1
127+
128+
- name: Publish NPM package
129+
run: |
130+
version=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
131+
npm publish --new-version="$version"
132+
working-directory: js
133+
env:
134+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/code_quality.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ jobs:
2929
- run: tox
3030
env:
3131
TOXENV: ${{ matrix.toxenv }}
32+
FORCE_COLOR: '1'

.github/workflows/release.yml

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

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Manage cookie information and let visitors give or reject consent for them.
1313
![Supported python versions](https://img.shields.io/pypi/pyversions/django-cookie-consent)
1414
![Supported Django versions](https://img.shields.io/pypi/djversions/django-cookie-consent)
1515
[![PyPI version][badge:pypi]][pypi]
16+
[![NPM version][badge:npm]][npm]
1617

1718
**Features**
1819

@@ -44,3 +45,5 @@ from the `docs` directory in this repository.
4445
[badge:docs]: https://readthedocs.org/projects/django-cookie-consent/badge/?version=latest
4546
[pypi]: https://pypi.org/project/django-cookie-consent/
4647
[badge:pypi]: https://img.shields.io/pypi/v/django-cookie-consent.svg
48+
[npm]: https://www.npmjs.com/package/django-cookie-consent
49+
[badge:npm]: https://img.shields.io/npm/v/django-cookie-consent

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,7 @@
237237

238238
# Documents to append as an appendix to all manuals.
239239
texinfo_appendices = []
240+
241+
linkcheck_ignore = [
242+
r"https://(www\.)?npmjs\.com.*", # IP/UA blocking...
243+
]

js/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20
1+
v24

js/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The cookiebar module is shipped in the Python package itself and available throu
66
django's staticfiles mechanism. This package is aimed at users wishing to include the
77
assets in their own Javascript bundle through webpack/vite/...
88

9+
[![PyPI version][badge:pypi]][pypi]
10+
911
## Installation
1012

1113
```bash
@@ -45,3 +47,6 @@ in the Python package:
4547
```bash
4648
npm run build:django-static
4749
```
50+
51+
[pypi]: https://pypi.org/project/django-cookie-consent/
52+
[badge:pypi]: https://img.shields.io/pypi/v/django-cookie-consent.svg

0 commit comments

Comments
 (0)