1- name : Build and upload to PyPI
1+ name : Build and publish to PyPI
22
33on :
44 release :
55 types : [published]
66
77jobs :
8- publish :
9- runs-on : ubuntu-22.04
8+ generate-rules :
9+ runs-on : ubuntu-24.04
10+
11+ steps :
12+ - name : Checkout repo
13+ uses : actions/checkout@v4
14+
15+ - name : Set up Python
16+ uses : actions/setup-python@v5
17+ with :
18+ python-version-file : pyproject.toml
19+ architecture : x64
20+
21+ - name : Install dependencies (and project)
22+ run : |
23+ pip install -U pip
24+ pip install -e .[scripts]
25+
26+ - name : Generate rules
27+ run : |
28+ python rules/generate_rules.py
29+
30+ - name : Save rules artifact
31+ uses : actions/upload-artifact@v4
32+ with :
33+ path : |
34+ src/zimscraperlib/rewriting/rules.py
35+ tests/rewriting/test_fuzzy_rules.py
36+ javascript/src/fuzzyRules.js
37+ javascript/test/fuzzyRules.js
38+ name : rules
39+ retention-days : 1
40+
41+ build-js :
42+ runs-on : ubuntu-24.04
43+ needs : generate-rules
44+
45+ steps :
46+ - name : Checkout repo
47+ uses : actions/checkout@v4
48+
49+ - name : Restore rules artifact
50+ uses : actions/download-artifact@v4
51+ with :
52+ name : rules
53+
54+ - name : Setup Node.JS
55+ uses : actions/setup-node@v4
56+ with :
57+ node-version-file : ' javascript/package.json'
58+
59+ - name : Install JS dependencies
60+ run : yarn install
61+ working-directory : javascript
62+
63+ - name : Build production JS
64+ run : yarn build-prod
65+ working-directory : javascript
66+
67+ - name : Save wombat-setup artifact
68+ uses : actions/upload-artifact@v4
69+ with :
70+ path : javascript/dist/wombatSetup.js
71+ name : wombat-setup
72+ retention-days : 1
73+
74+ publish-python :
75+ runs-on : ubuntu-24.04
76+ needs :
77+ - generate-rules # to have proper Python rules files (src and tests)
78+ - build-js # to have proper wombatSetup.js (needs to be included in sdist)
1079 permissions :
11- id-token : write # mandatory for PyPI trusted publishing
80+ id-token : write # mandatory for PyPI trusted publishing
1281
1382 steps :
14- - uses : actions/checkout@v3
83+ - name : Checkout repo
84+ uses : actions/checkout@v4
85+
86+ - name : Restore rules artifact
87+ uses : actions/download-artifact@v4
88+ with :
89+ name : rules
90+
91+ - name : Restore wombat-setup artifact
92+ uses : actions/download-artifact@v4
93+ with :
94+ name : wombat-setup
95+ path : src/zimscraperlib/rewriting/statics/wombatSetup.js
1596
1697 - name : Set up Python
17- uses : actions/setup-python@v4
98+ uses : actions/setup-python@v5
1899 with :
19100 python-version-file : pyproject.toml
20101 architecture : x64
@@ -24,5 +105,44 @@ jobs:
24105 pip install -U pip build
25106 python -m build --sdist --wheel
26107
27- - name : Upload to PyPI
108+ - name : Publish to PyPI
28109 uses : pypa/gh-action-pypi-publish@release/v1.8
110+ # OPTIONAL PUBLICATION TO NPM, NOT NEEDED BY SCRAPERS IN THE END
111+
112+ # publish-js:
113+ # runs-on: ubuntu-24.04
114+ # needs:
115+ # - generate-rules
116+
117+ # steps:
118+ # - name: Checkout repo
119+ # uses: actions/checkout@v4
120+
121+ # - name: Restore rules artifact
122+ # uses: actions/download-artifact@v4
123+ # with:
124+ # name: rules
125+
126+ # - name: Setup Node.JS
127+ # uses: actions/setup-node@v4
128+ # with:
129+ # node-version-file: 'javascript/package.json'
130+ # registry-url: 'https://registry.npmjs.org' # Setup .npmrc file to publish to npm
131+
132+ # - name: Install JS dependencies
133+ # run: yarn install
134+ # working-directory: javascript
135+
136+ # - name: Build production JS
137+ # run: yarn build-prod
138+ # working-directory: javascript
139+
140+ # - name: Build JS package
141+ # run: yarn pack
142+ # working-directory: javascript
143+
144+ # - name: Publish to NPM
145+ # run: npm publish $(ls *.tgz) --provenance --access public
146+ # working-directory: javascript
147+ # env:
148+ # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
0 commit comments