|
1 | | -name: release |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | 5 | types: [published] |
6 | 6 | workflow_dispatch: |
7 | 7 |
|
8 | | -# NOTE: parts inspired by https://cibuildwheel.pypa.io/en/stable/setup/ |
9 | | - |
10 | 8 | jobs: |
11 | 9 | build: |
12 | | - name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} |
13 | | - strategy: |
14 | | - fail-fast: true |
15 | | - matrix: |
16 | | - os: |
17 | | - - ubuntu-latest |
18 | | - - macos-15-intel # Intel runner |
19 | | - - macos-latest # Apple Silicon runner |
20 | | - - windows-latest |
21 | | - python-version: |
22 | | - - "10" |
23 | | - - "11" |
24 | | - - "12" |
25 | | - include: |
26 | | - - os: ubuntu-latest |
27 | | - platform: linux |
28 | | - - os: windows-latest |
29 | | - ls: dir |
30 | | - |
31 | | - env: |
32 | | - FASTSIM_DISABLE_NETWORK_TESTS: 1 |
33 | | - |
34 | | - runs-on: ${{ matrix.os }} |
35 | | - steps: |
36 | | - - uses: actions/checkout@v4 |
37 | | - |
38 | | - - name: set up rust |
39 | | - uses: dtolnay/rust-toolchain@stable |
40 | | - |
41 | | - - name: install rust target for MacOS 14+ (Apple Silicon) |
42 | | - run: rustup target add aarch64-apple-darwin |
43 | | - if: matrix.os == 'macos-latest' |
44 | | - |
45 | | - - name: install rust target for MacOS 15-intel (Intl Mac) |
46 | | - run: rustup target add x86_64-apple-darwin aarch64-apple-darwin |
47 | | - if: matrix.os == 'macos-15-intel' |
48 | | - |
49 | | - - name: set up Python |
50 | | - uses: actions/setup-python@v4 |
51 | | - # uses: actions/setup-python@v5 |
52 | | - with: |
53 | | - python-version: "3.${{ matrix.python-version }}" |
54 | | - |
55 | | - - name: run cargo tests |
56 | | - run: cargo test |
57 | | - |
58 | | - - name: Upgrade to latest pip |
59 | | - run: python -m pip install --upgrade pip |
60 | | - |
61 | | - - name: install Python dependencies |
62 | | - run: python -m pip install --upgrade setuptools wheel twine cibuildwheel pytest |
63 | | - |
64 | | - - name: build source distribution |
65 | | - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '10' |
66 | | - run: | |
67 | | - pip install -U setuptools-rust |
68 | | - python -c "import setuptools; setuptools.setup()" sdist |
69 | | -
|
70 | | - - name: Update minimum supported MacOS for Wheels for MacOS 15-intel (Intel Mac) |
71 | | - run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV |
72 | | - if: matrix.os == 'macos-15-intel' |
73 | | - |
74 | | - - name: build ${{ matrix.platform || matrix.os }} binaries |
75 | | - uses: pypa/cibuildwheel@v2.22.0 |
76 | | - env: |
77 | | - CIBW_BUILD: "cp3${{ matrix.python-version }}-*" |
78 | | - CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64" |
79 | | - # CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} |
80 | | - # TODO: why doesn't pytest work with cibuildwheel? |
81 | | - # CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests" |
82 | | - CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests" |
83 | | - # CIBW_ARCHS_MACOS: "universal2" |
84 | | - # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2 |
85 | | - CIBW_TEST_SKIP: "*_universal2:arm64" |
86 | | - CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' |
87 | | - CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' |
88 | | - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" |
89 | | - CIBW_MANYLINUX_I686_IMAGE: "manylinux2014" |
90 | | - CIBW_BEFORE_BUILD: > |
91 | | - pip install -U setuptools-rust && |
92 | | - rustup default stable && |
93 | | - rustup show |
94 | | - CIBW_BEFORE_BUILD_LINUX: > |
95 | | - yum -y install openssl openssl-devel && |
96 | | - pip install -U setuptools-rust && |
97 | | - curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && |
98 | | - rustup show |
99 | | - CIBW_BEFORE_BUILD_MACOS: > |
100 | | - rustup target add x86_64-apple-darwin |
101 | | - # - name: build windows 32bit binaries |
102 | | - # if: matrix.os == 'windows' |
103 | | - # run: cibuildwheel --output-dir dist |
104 | | - # env: |
105 | | - # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' |
106 | | - # CIBW_PLATFORM: windows |
107 | | - # CIBW_TEST_REQUIRES: 'pytest' |
108 | | - # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' |
109 | | - # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' |
110 | | - # CIBW_BEFORE_BUILD: > |
111 | | - # pip install -U setuptools-rust && |
112 | | - # rustup toolchain install nightly-i686-pc-windows-msvc && |
113 | | - # rustup default nightly-i686-pc-windows-msvc && |
114 | | - # rustup override set nightly-i686-pc-windows-msvc && |
115 | | - # rustup show |
116 | | - |
117 | | - - name: list wheelhouse files |
118 | | - run: ${{ matrix.ls || 'ls -lh' }} ./wheelhouse/ |
119 | | - |
120 | | - - uses: actions/upload-artifact@v4 |
121 | | - with: |
122 | | - name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }}-${{ strategy.job-index }} |
123 | | - path: ./wheelhouse/*.whl |
| 10 | + uses: ./.github/workflows/reusable_build.yaml |
124 | 11 |
|
125 | 12 | release: |
126 | 13 | needs: build |
127 | | - name: release files to PyPI |
| 14 | + name: Publish release artifacts |
128 | 15 | runs-on: ubuntu-latest |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + shell: pixi run -e release bash -e {0} |
129 | 19 | # Protection Strategies -- use ONE of the following two lines: |
130 | 20 | # publish on via explicit publish |
131 | 21 | if: github.event_name == 'release' && github.event.action == 'published' |
132 | 22 | # publish on tag starting w/ 'v' |
133 | 23 | # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
134 | 24 | steps: |
135 | | - - name: download files |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Download files |
136 | 28 | uses: actions/download-artifact@v4 |
137 | 29 | with: |
138 | 30 | merge-multiple: true |
139 | 31 | path: artifact |
140 | 32 |
|
141 | | - - name: set up Python 3.11 |
142 | | - uses: actions/setup-python@v4 |
| 33 | + - name: Set up Pixi |
| 34 | + uses: prefix-dev/setup-pixi@v0.8.14 |
143 | 35 | with: |
144 | | - python-version: "3.11" |
| 36 | + environments: release |
145 | 37 |
|
146 | | - - run: pip install twine |
| 38 | + - name: Check distribution with Twine |
| 39 | + run: python -m twine check ./artifact/* |
147 | 40 |
|
148 | | - - run: twine check ./artifact/* |
| 41 | + - name: Dry-run Rust crate publish |
| 42 | + run: | |
| 43 | + cargo publish --manifest-path fastsim-core/fastsim-proc-macros/Cargo.toml --locked --dry-run |
| 44 | + cargo publish --manifest-path fastsim-core/Cargo.toml --locked --dry-run |
| 45 | + # cargo publish --manifest-path fastsim-cli/Cargo.toml --locked --dry-run |
149 | 46 |
|
150 | 47 | - name: Publish distribution to Test PyPI |
151 | | - run: twine upload -r testpypi ./artifact/* |
| 48 | + run: python -m twine upload -r testpypi ./artifact/* |
152 | 49 | env: |
153 | 50 | TWINE_USERNAME: __token__ |
154 | 51 | TWINE_PASSWORD: ${{ secrets.FASTSIM_TEST_PYPI_TOKEN }} |
155 | 52 |
|
| 53 | + - name: Publish Rust crates to crates.io |
| 54 | + run: | |
| 55 | + cargo publish --manifest-path fastsim-core/fastsim-proc-macros/Cargo.toml --locked |
| 56 | + cargo publish --manifest-path fastsim-core/Cargo.toml --locked |
| 57 | + # cargo publish --manifest-path fastsim-cli/Cargo.toml --locked |
| 58 | + env: |
| 59 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 60 | + |
156 | 61 | - name: Upload files to PyPI |
157 | | - run: twine upload ./artifact/* |
| 62 | + run: python -m twine upload ./artifact/* |
158 | 63 | env: |
159 | 64 | TWINE_USERNAME: __token__ |
160 | 65 | TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }} |
0 commit comments