|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "v*" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + cpython: |
| 13 | + name: Build CPython |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Setup WASI-SDK |
| 19 | + shell: bash |
| 20 | + run: | |
| 21 | + cd /tmp |
| 22 | + wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz |
| 23 | + tar -xf wasi-sdk-16.0-linux.tar.gz |
| 24 | + cp -r wasi-sdk-16.0 /opt/wasi-sdk |
| 25 | +
|
| 26 | + - name: Build CPython |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + git submodule update --init --recursive |
| 30 | + mkdir -p cpython/builddir/wasi |
| 31 | + mkdir -p cpython/builddir/build |
| 32 | + cd cpython/builddir/build |
| 33 | + ../../configure --prefix=$(pwd)/install --enable-optimizations |
| 34 | + make |
| 35 | + cd ../wasi |
| 36 | + CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi ../../Tools/wasm/wasi-env \ |
| 37 | + ../../configure -C --host=wasm32-unknown-wasi --build=$(../../config.guess) \ |
| 38 | + --with-build-python=$(pwd)/../build/python --prefix=$(pwd)/install --disable-test-modules |
| 39 | + make |
| 40 | + make install |
| 41 | + cd ../../.. |
| 42 | +
|
| 43 | + - name: Publish CPython |
| 44 | + uses: actions/upload-artifact@v3 |
| 45 | + with: |
| 46 | + name: cpython-wasi |
| 47 | + path: | |
| 48 | + cpython/builddir/wasi |
| 49 | + !cpython/builddir/wasi/**/*.pyc |
| 50 | + !cpython/builddir/wasi/**/*.whl |
| 51 | + !cpython/builddir/wasi/**/Makefile |
| 52 | + !cpython/builddir/wasi/**/Changelog |
| 53 | + !cpython/builddir/wasi/**/NEWS.txt |
| 54 | +
|
| 55 | + release: |
| 56 | + name: Build spin-python |
| 57 | + needs: cpython |
| 58 | + runs-on: ${{ matrix.config.os }} |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + config: |
| 63 | + - { |
| 64 | + os: "ubuntu-latest", |
| 65 | + arch: "amd64", |
| 66 | + wasiSDK: "linux", |
| 67 | + extension: "", |
| 68 | + buildArgs: "", |
| 69 | + target: "", |
| 70 | + targetDir: "target/release", |
| 71 | + } |
| 72 | + - { |
| 73 | + os: "ubuntu-latest", |
| 74 | + arch: "aarch64", |
| 75 | + wasiSDK: "linux", |
| 76 | + extension: "", |
| 77 | + buildArgs: "\"--target aarch64-unknown-linux-gnu\"", |
| 78 | + target: "aarch64-unknown-linux-gnu", |
| 79 | + targetDir: "target/aarch64-unknown-linux-gnu/release", |
| 80 | + } |
| 81 | + - { |
| 82 | + os: "macos-latest", |
| 83 | + arch: "amd64", |
| 84 | + wasiSDK: "macos", |
| 85 | + extension: "", |
| 86 | + buildArgs: "", |
| 87 | + target: "", |
| 88 | + targetDir: "target/release", |
| 89 | + } |
| 90 | + - { |
| 91 | + os: "macos-latest", |
| 92 | + arch: "aarch64", |
| 93 | + wasiSDK: "macos", |
| 94 | + extension: "", |
| 95 | + buildArgs: "\"--target aarch64-apple-darwin\"", |
| 96 | + target: "aarch64-apple-darwin", |
| 97 | + targetDir: "target/aarch64-apple-darwin/release/", |
| 98 | + } |
| 99 | + - { |
| 100 | + os: "windows-latest", |
| 101 | + arch: "amd64", |
| 102 | + wasiSDK: "", |
| 103 | + extension: ".exe", |
| 104 | + buildArgs: "", |
| 105 | + target: "", |
| 106 | + targetDir: "target/release", |
| 107 | + } |
| 108 | + steps: |
| 109 | + - uses: actions/checkout@v3 |
| 110 | + - name: Install latest Rust stable toolchain |
| 111 | + uses: actions-rs/toolchain@v1 |
| 112 | + with: |
| 113 | + toolchain: stable |
| 114 | + default: true |
| 115 | + target: ${{ matrix.config.target }} |
| 116 | + |
| 117 | + - name: set the release version (tag) |
| 118 | + if: startsWith(github.ref, 'refs/tags/v') |
| 119 | + shell: bash |
| 120 | + run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV |
| 121 | + |
| 122 | + - name: set the release version (main) |
| 123 | + if: github.ref == 'refs/heads/main' |
| 124 | + shell: bash |
| 125 | + run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV |
| 126 | + |
| 127 | + - name: lowercase the runner OS name |
| 128 | + shell: bash |
| 129 | + run: | |
| 130 | + OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]') |
| 131 | + echo "RUNNER_OS=$OS" >> $GITHUB_ENV |
| 132 | +
|
| 133 | + - name: "Install Wasm Rust target" |
| 134 | + shell: bash |
| 135 | + run: rustup target add wasm32-wasi |
| 136 | + |
| 137 | + - name: Setup WASI-SDK |
| 138 | + if: runner.os != 'Windows' |
| 139 | + shell: bash |
| 140 | + run: | |
| 141 | + cd /tmp |
| 142 | + curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-${{ matrix.config.wasiSDK }}.tar.gz |
| 143 | + tar -xf wasi-sdk-16.0-${{ matrix.config.wasiSDK }}.tar.gz |
| 144 | +
|
| 145 | + sudo mv wasi-sdk-16.0 /opt/wasi-sdk |
| 146 | +
|
| 147 | + - name: Setup WASI-SDK on Windows |
| 148 | + if: runner.os == 'Windows' |
| 149 | + shell: bash |
| 150 | + run: | |
| 151 | + curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-mingw.tar.gz |
| 152 | + tar -xf wasi-sdk-16.0-mingw.tar.gz |
| 153 | +
|
| 154 | + - name: Download CPython |
| 155 | + uses: actions/download-artifact@v3 |
| 156 | + with: |
| 157 | + name: cpython-wasi |
| 158 | + path: cpython/builddir/wasi |
| 159 | + |
| 160 | + - name: setup for cross-compiled linux aarch64 build |
| 161 | + if: matrix.config.target == 'aarch64-unknown-linux-gnu' |
| 162 | + run: | |
| 163 | + sudo apt update |
| 164 | + sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu |
| 165 | + echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml |
| 166 | + echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml |
| 167 | +
|
| 168 | + - name: Build spin-python |
| 169 | + shell: bash |
| 170 | + run: | |
| 171 | + if [ "${{ runner.os}}" == "Windows" ]; then |
| 172 | + export WASI_SDK_PATH="$(cygpath -w $(pwd)/wasi-sdk-16.0)" |
| 173 | + fi |
| 174 | + make BUILD_TARGET=${{ matrix.config.buildArgs }} |
| 175 | +
|
| 176 | + - name: Package as plugins tar |
| 177 | + shell: bash |
| 178 | + run: | |
| 179 | + mkdir -v _dist |
| 180 | + cp ${{ matrix.config.targetDir }}/spin-python${{ matrix.config.extension }} _dist/py2wasm${{ matrix.config.extension }} |
| 181 | + cp LICENSE _dist/py2wasm.license |
| 182 | + cd _dist |
| 183 | + tar czf py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz py2wasm.license py2wasm${{ matrix.config.extension }} |
| 184 | +
|
| 185 | + - name: Upload build artifact |
| 186 | + uses: actions/upload-artifact@v3 |
| 187 | + with: |
| 188 | + name: py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz |
| 189 | + path: _dist/py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz |
| 190 | + |
| 191 | + - name: upload binary to Github release |
| 192 | + if: startsWith(github.ref, 'refs/tags/v') |
| 193 | + uses: svenstaro/upload-release-action@v2 |
| 194 | + with: |
| 195 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 196 | + file: _dist/py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz |
| 197 | + tag: ${{ github.ref }} |
| 198 | + |
| 199 | + checksums: |
| 200 | + name: generate checksums |
| 201 | + runs-on: ubuntu-latest |
| 202 | + needs: release |
| 203 | + steps: |
| 204 | + |
| 205 | + - name: set the release version (tag) |
| 206 | + if: startsWith(github.ref, 'refs/tags/v') |
| 207 | + shell: bash |
| 208 | + run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV |
| 209 | + |
| 210 | + - name: download release assets |
| 211 | + uses: actions/download-artifact@v3 |
| 212 | + |
| 213 | + - name: generate checksums |
| 214 | + run: | |
| 215 | + ls -lh |
| 216 | + sha256sum py2wasm*.tar.gz/py2wasm*.tar.gz > checksums-${{ env.RELEASE_VERSION }}.txt |
| 217 | +
|
| 218 | + - name: upload checksums to Github release |
| 219 | + if: startsWith(github.ref, 'refs/tags/v') |
| 220 | + uses: svenstaro/upload-release-action@v2 |
| 221 | + with: |
| 222 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 223 | + file: checksums-${{ env.RELEASE_VERSION }}.txt |
| 224 | + tag: ${{ github.ref }} |
0 commit comments