-
Notifications
You must be signed in to change notification settings - Fork 19
193 lines (178 loc) · 5.43 KB
/
build.yml
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: build
on:
push:
pull_request:
jobs:
rust-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test and Clippy
run: |
cargo test
cargo clippy --all-features -- -D warnings
javascript:
runs-on: ubuntu-latest
needs: rust-test
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
id: build
working-directory: javascript
run: |
cp ../README.md ./
npm ci
npm run build
npm pack
- name: Install test dependencies
working-directory: javascript/tests
run: npm ci && npx playwright install --with-deps
- name: Run tests
working-directory: javascript
run: make test
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: javascript
path: javascript/evmole-*.tgz
python-wheel:
needs: rust-test
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
platform:
- runner: ubuntu-latest
os: linux
target: x86_64
- runner: windows-latest
os: windows
target: x64
- runner: macos-latest
os: macos
target: universal2-apple-darwin
runs-on: ${{ matrix.platform.runner }}
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.7.6
target: ${{ matrix.platform.target }}
manylinux: auto
args: -i ${{ matrix.python-version }} --release --out dist
- name: Install wheel
run: pip3 install ${{ matrix.platform.os == 'windows' && '(get-item .\dist\*.whl)' || 'dist/*.whl' }}
- name: Test
run: python3 python/test_python.py
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-${{ matrix.platform.os}}-${{ matrix.python-version }}
path: dist/*.whl
compression-level: 0
python-sdist:
runs-on: ubuntu-latest
needs: rust-test
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
maturin-version: 1.7.6
command: sdist
args: --out dist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-sdist
path: dist
compression-level: 0
python-sdist-test:
# ubuntu-latest image (https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md) have Rust installed
runs-on: ubuntu-latest
needs: python-sdist
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.13
allow-prereleases: true
- uses: actions/download-artifact@v4
with:
name: python-sdist
- name: Build and install wheel
run: pip3 install *.tar.gz
- name: Test
run: python3 python/test_python.py
release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # only on tagged releases
needs: [javascript, python-wheel, python-sdist, python-sdist-test]
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # need tags to generate release notes
- name: Publish rust
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}
run: cargo publish --allow-dirty
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
- name: Release Notes
run: |
echo '## Changes since previous release:' > changelog.md
git log --oneline $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:"- [%h](https://github.com/cdump/evmole/commit/%H) %s" >> changelog.md
cat changelog.md
- name: Download Python Artifacts
uses: actions/download-artifact@v4
with:
pattern: python-*
path: dist-py
merge-multiple: true
- name: Download Javascript Artifacts
uses: actions/download-artifact@v4
with:
name: javascript
path: ./javascript/
- name: Github Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
body_path: changelog.md
files: |
javascript/evmole-*.tgz
dist-py/*
- name: Publish javascript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: javascript
run: npm publish --provenance *.tgz
- name: Publish python
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
packages-dir: dist-py/