1
+ # (C) Copyright 2024- ECMWF.
2
+ #
3
+ # This software is licensed under the terms of the Apache Licence Version 2.0
4
+ # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5
+ # In applying this licence, ECMWF does not waive the privileges and immunities
6
+ # granted to it by virtue of its status as an intergovernmental organisation
7
+ # nor does it submit to any jurisdiction.
8
+
9
+ name : Build MacOS ARM
10
+
11
+ on :
12
+ # Trigger the workflow manually
13
+ workflow_dispatch : ~
14
+
15
+ # allow to be called from another workflow
16
+ workflow_call : ~
17
+
18
+ # repository_dispatch:
19
+ # types: [eccodes-updated]
20
+
21
+ push :
22
+ paths :
23
+ - ' scripts/common.sh'
24
+ - ' scripts/select-python-macos.sh'
25
+ - ' scripts/build-macos.sh'
26
+ - ' scripts/wheel-macos.sh'
27
+ - ' scripts/test-macos.sh'
28
+ - ' scripts/copy-licences.py'
29
+ - ' .github/workflows/build-wheel-macos.yml'
30
+
31
+ # We don't use "actions/setup-python@v4" as it installs a universal python
32
+ # which creates universal wheels. We want to create wheels for the specific
33
+ # architecture we are running on.
34
+
35
+ jobs :
36
+
37
+ build :
38
+
39
+ # if: false # for temporarily disabling for debugging
40
+
41
+ strategy :
42
+ matrix :
43
+ arch_type : [ARM64, X64]
44
+ runs-on : [self-hosted, macOS, "${{ matrix.arch_type }}"]
45
+
46
+ name : Build
47
+
48
+ steps :
49
+
50
+ - run : sudo mkdir -p /Users/runner
51
+ - run : sudo chown administrator:staff /Users/runner
52
+
53
+ - uses : actions/checkout@v2
54
+
55
+ - run : ./scripts/build-macos.sh "3.10"
56
+
57
+ - run : ./scripts/wheel-macos.sh "3.9"
58
+ - run : ls -l wheelhouse
59
+ - uses : actions/upload-artifact@v4
60
+ name : Upload wheel 3.9 ${{ matrix.arch_type }}
61
+ with :
62
+ name : wheel-macos-${{ matrix.arch_type }}-3.9
63
+ path : wheelhouse/*.whl
64
+ - run : rm -fr wheelhouse
65
+
66
+ - run : ./scripts/wheel-macos.sh "3.10"
67
+ - run : ls -l wheelhouse
68
+ - uses : actions/upload-artifact@v4
69
+ name : Upload wheel 3.10 ${{ matrix.arch_type }}
70
+ with :
71
+ name : wheel-macos-${{ matrix.arch_type }}-3.10
72
+ path : wheelhouse/*.whl
73
+ - run : rm -fr wheelhouse
74
+
75
+ - run : ./scripts/wheel-macos.sh "3.11"
76
+ - run : ls -l wheelhouse
77
+ - uses : actions/upload-artifact@v4
78
+ name : Upload wheel 3.11 ${{ matrix.arch_type }}
79
+ with :
80
+ name : wheel-macos-${{ matrix.arch_type }}-3.11
81
+ path : wheelhouse/*.whl
82
+ - run : rm -fr wheelhouse
83
+
84
+ - run : ./scripts/wheel-macos.sh "3.12"
85
+ - run : ls -l wheelhouse
86
+ - uses : actions/upload-artifact@v4
87
+ name : Upload wheel 3.12 ${{ matrix.arch_type }}
88
+ with :
89
+ name : wheel-macos-${{ matrix.arch_type }}-3.12
90
+ path : wheelhouse/*.whl
91
+ - run : rm -fr wheelhouse
92
+
93
+ test :
94
+ needs : build
95
+
96
+ strategy :
97
+ fail-fast : true
98
+ max-parallel : 1
99
+ matrix :
100
+ arch_type : [ARM64, X64]
101
+ python-version : ["3.9", "3.10", "3.11", "3.12"]
102
+
103
+ runs-on : [self-hosted, macOS, "${{ matrix.arch_type }}"]
104
+
105
+ name : Test with Python ${{ matrix.python-version }} ${{ matrix.arch_type }}
106
+
107
+ steps :
108
+
109
+ - uses : actions/checkout@v2
110
+
111
+ - uses : actions/download-artifact@v4
112
+ with :
113
+ name : wheel-macos-${{ matrix.arch_type }}-${{ matrix.python-version }}
114
+
115
+ - run : ./scripts/test-macos.sh ${{ matrix.python-version }}
116
+
117
+
118
+ deploy :
119
+
120
+ if : ${{ github.ref_type == 'tag' || github.event_name == 'release' }}
121
+
122
+ needs : [test, build]
123
+
124
+ name : Deploy wheel ${{ matrix.python-version }} ${{ matrix.arch_type }}
125
+
126
+ strategy :
127
+ fail-fast : true
128
+ max-parallel : 1
129
+ matrix :
130
+ arch_type : [ARM64, X64]
131
+ python-version : ["3.9", "3.10", "3.11", "3.12"]
132
+
133
+ runs-on : [self-hosted, macOS, "${{ matrix.arch_type }}"]
134
+
135
+ steps :
136
+
137
+ - run : mkdir artifact-${{ matrix.arch_type }}-${{ matrix.python-version }}
138
+
139
+ - uses : actions/download-artifact@v4
140
+ with :
141
+ name : wheel-macos-${{ matrix.arch_type }}-${{ matrix.python-version }}
142
+ path : artifact-${{ matrix.arch_type }}-${{ matrix.python-version }}
143
+
144
+ - run : |
145
+ source ./scripts/select-python-macos.sh ${{ matrix.python-version }}
146
+ VENV_DIR=./dist_venv_${{ matrix.python-version }}
147
+ rm -rf ${VENV_DIR}
148
+ python3 -m venv ${VENV_DIR}
149
+ source ${VENV_DIR}/bin/activate
150
+ pip3 install twine
151
+ ls -l artifact-${{ matrix.arch_type }}-${{ matrix.python-version }}/*.whl
152
+ twine upload artifact-${{ matrix.arch_type }}-${{ matrix.python-version }}/*.whl
153
+ env:
154
+ TWINE_USERNAME: __token__
155
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
0 commit comments