Skip to content

Commit 625db06

Browse files
👷 [#120] Automate publishing of Python and NPM packages
* Publish to NPM automatically * Use trusted publishing for PyPI packages
1 parent 625abd1 commit 625db06

File tree

2 files changed

+48
-56
lines changed

2 files changed

+48
-56
lines changed

.github/workflows/ci.yml

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

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)