-
-
Notifications
You must be signed in to change notification settings - Fork 19
170 lines (136 loc) · 4.11 KB
/
Publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Build and publish to PyPI / NPM
on:
release:
types: [published]
push:
branches:
- content_rewriting
jobs:
generate-rules:
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
architecture: x64
- name: Install dependencies (and project)
run: |
pip install -U pip
pip install -e .[scripts]
- name: Generate rules
run: |
python rules/generate_rules.py
- name: Save rules artifact
uses: actions/upload-artifact@v4
with:
path: |
src/zimscraperlib/rewriting/rules.py
tests/rewriting/test_fuzzy_rules.py
javascript/src/fuzzyRules.js
javascript/test/fuzzyRules.js
name: rules
retention-days: 1
build-js:
runs-on: ubuntu-24.04
needs: generate-rules
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore rules artifact
uses: actions/download-artifact@v4
with:
name: rules
- name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version-file: 'javascript/package.json'
- name: Install JS dependencies
run: yarn install
working-directory: javascript
- name: Build production JS
run: yarn build-prod
working-directory: javascript
- name: Save wombat-setup artifact
uses: actions/upload-artifact@v4
with:
path: javascript/dist/wombatSetup.js
name: wombat-setup
retention-days: 1
publish-python:
runs-on: ubuntu-24.04
needs:
- generate-rules
- build-js
permissions:
id-token: write # mandatory for PyPI trusted publishing
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore rules artifact
uses: actions/download-artifact@v4
with:
name: rules
- name: Restore wombat-setup artifact
uses: actions/download-artifact@v4
with:
name: wombat-setup
path: src/zimscraperlib/rewriting/statics/wombatSetup.js
- run: ls -lah src/zimscraperlib/rewriting/statics
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
architecture: x64
- run: ls -lah src/zimscraperlib/rewriting/statics
- name: Build packages
run: |
pip install -U pip build
python -m build --sdist --wheel
- run: ls -lah src/zimscraperlib/rewriting/statics
- name: Save temp-python artifact
uses: actions/upload-artifact@v4
with:
path: dist
name: temp-python
retention-days: 1
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1.8
publish-js:
runs-on: ubuntu-24.04
needs:
- generate-rules
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore rules artifact
uses: actions/download-artifact@v4
with:
name: rules
- name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version-file: 'javascript/package.json'
registry-url: 'https://registry.npmjs.org' # Setup .npmrc file to publish to npm
- name: Install JS dependencies
run: yarn install
working-directory: javascript
- name: Build production JS
run: yarn build-prod
working-directory: javascript
- name: Build JS package
run: yarn pack
working-directory: javascript
- name: Save temp-js artifact
uses: actions/upload-artifact@v4
with:
path: javascript/*.tgz
name: temp-js
retention-days: 1
- name: Publish to NPM
run: npm publish $(ls *.tgz) --dry-run --provenance --access public
working-directory: javascript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}