-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (191 loc) · 6.99 KB
/
multiplatform-build.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
---
name: Multiplatform -- Build Python wheel using golang's gopy
# Based on https://github.com/tuananh/py-event-ruler/blob/0129d15e17d0023863a4d0e0e25e5256988b5c5b/.github/workflows/publish.yml
on:
push:
branches:
- main
defaults:
run:
shell: bash
jobs:
call-lint:
uses: ./.github/workflows/lint-on-macos.yaml
build_macos:
permissions:
contents: write
strategy:
fail-fast: true
matrix:
os_version: [ 13 ]
go-version: [ 1.22.x ]
python3_version: [ 11 ]
# go-version: [ '1.19', '1.20', '1.22.x' ]
runs-on: macos-${{ matrix.os_version }}
steps:
- uses: actions/checkout@v4
- name: Setup Docker on macOS using Colima, Lima-VM, and Homebrew
uses: douglascamata/setup-docker-macos-action@v1-alpha
- name: Verify docker Installation
run: |
docker --version
docker ps
- name: Setup vagrant
run: |
brew install vagrant
vagrant --version
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: go.sum
- name: Install dependencies
run: go get .
- name: Test with Go
run: go test
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install poetry
# Look for go/bin (skip, we know it exists)
echo '$HOME/'
ls -la "$HOME/"
echo '$HOME/go/'
ls -la "$HOME/go/"
- name: Add Go bin directory to PATH
run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
# FIXME: Add more caching
- name: Add gopy dependencies and build wheel
run: |
# Since we don't have our wheel build / install configured yet we use '--no-root'
poetry install --no-root
source .venv/bin/activate
# Add Go bin directory to PATH
echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/go-python/gopy@latest
poetry run pip install --upgrade setuptools wheel
gopy build --output=ohpygossh -vm=python3 .
poetry run python3 setup.py bdist_wheel
- name: Test Python wheel
run: |
# Test wheel installation
pip install dist/ohpygossh-0.0.8-py3-none-any.whl
# Test wheel functionality
python3 validate_ohpygossh.py
# Name properly
mv dist/ohpygossh-0.0.8-py3-none-any.whl dist/ohpygossh-0.0.8-none-any-macosx_11_0_x86_64.whl
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
# name: wheels-macos${{ matrix.os_version }}-py3${{ matrix.python3_version }}-${{ matrix.arch_cibw_go[0] }}
name: wheels-macos${{ matrix.os_version }}-py3${{ matrix.python3_version }}-x86_64
path: ./dist/*.whl
build_linux_x86_64:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: true
matrix:
go-version: [1.22.x]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install Vagrant
run: sudo apt-get update && sudo apt-get install -y vagrant
- name: Verify docker and vagrant installation
run: |
docker --version
docker ps
vagrant --version
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: go.sum
- name: Install dependencies
run: go get .
- name: Test with Go
run: go test
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install poetry
# Look for go/bin (skip, we know it exists)
echo '$HOME/'
ls -la "$HOME/"
echo '$HOME/go/'
ls -la "$HOME/go/"
- name: Add Go bin directory to PATH
run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
# FIXME: Add more caching
- name: Add gopy dependencies and build wheel
run: |
# Since we don't have our wheel build / install configured yet we use '--no-root'
poetry install --no-root
source .venv/bin/activate
# Add Go bin directory to PATH
echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/go-python/gopy@latest
poetry run pip install --upgrade setuptools wheel
gopy build --output=ohpygossh -vm=python3 .
poetry run python3 setup.py bdist_wheel
- name: Test Python wheel
run: |
# Test wheel installation
pip install dist/ohpygossh-0.0.8-py3-none-any.whl
# Test wheel functionality
python3 validate_ohpygossh.py
# Name properly
mv dist/ohpygossh-0.0.8-py3-none-any.whl dist/ohpygossh-0.0.8-none-any-manylinux2014_x86_64.whl
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-linux-amd64
path: ./dist/*.whl
release:
permissions:
contents: write
needs: [build_macos, build_linux_x86_64]
runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Collect all wheels
run: |
# ls -R
mkdir dist
for f in $(find . -type f -name '*.whl'); do mv ${f} dist; done;
ls -R dist
- name: Store version
run: |
pip install poetry
PROJECT_VESION=$(poetry version -s)
echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV
- name: Install twine
run: pip install twine
- name: Upload to PyPI
env:
TWINE_UPLOAD_URL: https://upload.pypi.org/legacy/
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --password "$PYPI_PASSWORD" --user "$PYPI_USERNAME" --repository-url "$TWINE_UPLOAD_URL" dist/*
- uses: ncipollo/release-action@v1
with:
artifacts: |
README.md,
dist/*.whl
body: OhPyGoSSH version ${{ env.PROJECT_VESION }}
# tag: "dev-${{ github.job }}-${{ env.PROJECT_VESION }}"
tag: v${{ env.PROJECT_VESION }}