|
| 1 | +name: Jupyter Kernel Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + generate: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version: "20" |
| 21 | + |
| 22 | + - name: Install tree-sitter-cli |
| 23 | + run: npm install -g tree-sitter-cli |
| 24 | + |
| 25 | + - name: Generate parser |
| 26 | + working-directory: tree-sitter-ggsql |
| 27 | + run: tree-sitter generate |
| 28 | + |
| 29 | + - uses: actions/upload-artifact@v4 |
| 30 | + with: |
| 31 | + name: tree-sitter-generated |
| 32 | + path: tree-sitter-ggsql/src/ |
| 33 | + |
| 34 | + linux: |
| 35 | + needs: generate |
| 36 | + runs-on: ubuntu-latest |
| 37 | + strategy: |
| 38 | + matrix: |
| 39 | + target: [x86_64, aarch64] |
| 40 | + env: |
| 41 | + GGSQL_SKIP_GENERATE: "1" |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - uses: actions/download-artifact@v4 |
| 46 | + with: |
| 47 | + name: tree-sitter-generated |
| 48 | + path: tree-sitter-ggsql/src/ |
| 49 | + |
| 50 | + - name: Build wheels |
| 51 | + uses: PyO3/maturin-action@v1 |
| 52 | + with: |
| 53 | + target: ${{ matrix.target }} |
| 54 | + args: --release --out dist |
| 55 | + working-directory: ggsql-jupyter |
| 56 | + manylinux: 2_28 |
| 57 | + docker-options: -e GGSQL_SKIP_GENERATE=1 |
| 58 | + |
| 59 | + - uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: jupyter-wheels-linux-${{ matrix.target }} |
| 62 | + path: ggsql-jupyter/dist |
| 63 | + |
| 64 | + macos: |
| 65 | + needs: generate |
| 66 | + runs-on: ${{ matrix.runner }} |
| 67 | + strategy: |
| 68 | + matrix: |
| 69 | + include: |
| 70 | + - target: x86_64 |
| 71 | + runner: macos-latest |
| 72 | + - target: aarch64 |
| 73 | + runner: macos-latest |
| 74 | + env: |
| 75 | + GGSQL_SKIP_GENERATE: "1" |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + name: tree-sitter-generated |
| 82 | + path: tree-sitter-ggsql/src/ |
| 83 | + |
| 84 | + - name: Build wheels |
| 85 | + uses: PyO3/maturin-action@v1 |
| 86 | + with: |
| 87 | + target: ${{ matrix.target }} |
| 88 | + args: --release --out dist |
| 89 | + working-directory: ggsql-jupyter |
| 90 | + |
| 91 | + - uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: jupyter-wheels-macos-${{ matrix.target }} |
| 94 | + path: ggsql-jupyter/dist |
| 95 | + |
| 96 | + windows: |
| 97 | + needs: generate |
| 98 | + runs-on: windows-latest |
| 99 | + env: |
| 100 | + GGSQL_SKIP_GENERATE: "1" |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v4 |
| 103 | + |
| 104 | + - uses: actions/download-artifact@v4 |
| 105 | + with: |
| 106 | + name: tree-sitter-generated |
| 107 | + path: tree-sitter-ggsql/src/ |
| 108 | + |
| 109 | + - name: Build wheels |
| 110 | + uses: PyO3/maturin-action@v1 |
| 111 | + with: |
| 112 | + target: x64 |
| 113 | + args: --release --out dist |
| 114 | + working-directory: ggsql-jupyter |
| 115 | + |
| 116 | + - uses: actions/upload-artifact@v4 |
| 117 | + with: |
| 118 | + name: jupyter-wheels-windows-x64 |
| 119 | + path: ggsql-jupyter/dist |
| 120 | + |
| 121 | + sdist: |
| 122 | + needs: generate |
| 123 | + runs-on: ubuntu-latest |
| 124 | + env: |
| 125 | + GGSQL_SKIP_GENERATE: "1" |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@v4 |
| 128 | + |
| 129 | + - uses: actions/download-artifact@v4 |
| 130 | + with: |
| 131 | + name: tree-sitter-generated |
| 132 | + path: tree-sitter-ggsql/src/ |
| 133 | + |
| 134 | + - name: Build sdist |
| 135 | + uses: PyO3/maturin-action@v1 |
| 136 | + with: |
| 137 | + command: sdist |
| 138 | + args: --out dist |
| 139 | + working-directory: ggsql-jupyter |
| 140 | + |
| 141 | + - uses: actions/upload-artifact@v4 |
| 142 | + with: |
| 143 | + name: jupyter-wheels-sdist |
| 144 | + path: ggsql-jupyter/dist |
| 145 | + |
| 146 | + publish: |
| 147 | + needs: [linux, macos, windows, sdist] |
| 148 | + runs-on: ubuntu-latest |
| 149 | + if: startsWith(github.ref, 'refs/tags/') |
| 150 | + environment: pypi-jupyter |
| 151 | + permissions: |
| 152 | + id-token: write |
| 153 | + steps: |
| 154 | + - uses: actions/download-artifact@v4 |
| 155 | + with: |
| 156 | + pattern: jupyter-wheels-* |
| 157 | + merge-multiple: true |
| 158 | + path: dist |
| 159 | + |
| 160 | + - name: List wheels |
| 161 | + run: ls -lh dist/ |
| 162 | + |
| 163 | + - name: Publish to PyPI |
| 164 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 165 | + |
| 166 | + github-release: |
| 167 | + needs: [linux, macos, windows] |
| 168 | + runs-on: ubuntu-latest |
| 169 | + if: startsWith(github.ref, 'refs/tags/') |
| 170 | + permissions: |
| 171 | + contents: write |
| 172 | + steps: |
| 173 | + - uses: actions/download-artifact@v4 |
| 174 | + with: |
| 175 | + pattern: jupyter-wheels-* |
| 176 | + path: artifacts |
| 177 | + |
| 178 | + - name: Extract binaries from wheels |
| 179 | + run: | |
| 180 | + mkdir -p binaries |
| 181 | +
|
| 182 | + # Linux x86_64 |
| 183 | + unzip -j artifacts/jupyter-wheels-linux-x86_64/*manylinux*x86_64*.whl \ |
| 184 | + "*.data/scripts/ggsql-jupyter" -d /tmp/extract |
| 185 | + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-linux-x64 |
| 186 | + rm -rf /tmp/extract |
| 187 | +
|
| 188 | + # Linux aarch64 |
| 189 | + unzip -j artifacts/jupyter-wheels-linux-aarch64/*manylinux*aarch64*.whl \ |
| 190 | + "*.data/scripts/ggsql-jupyter" -d /tmp/extract |
| 191 | + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-linux-arm64 |
| 192 | + rm -rf /tmp/extract |
| 193 | +
|
| 194 | + # macOS x86_64 |
| 195 | + unzip -j artifacts/jupyter-wheels-macos-x86_64/*macosx*x86_64*.whl \ |
| 196 | + "*.data/scripts/ggsql-jupyter" -d /tmp/extract |
| 197 | + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-macos-x64 |
| 198 | + rm -rf /tmp/extract |
| 199 | +
|
| 200 | + # macOS aarch64 |
| 201 | + unzip -j artifacts/jupyter-wheels-macos-aarch64/*macosx*arm64*.whl \ |
| 202 | + "*.data/scripts/ggsql-jupyter" -d /tmp/extract |
| 203 | + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-macos-arm64 |
| 204 | + rm -rf /tmp/extract |
| 205 | +
|
| 206 | + # Windows x64 |
| 207 | + unzip -j artifacts/jupyter-wheels-windows-x64/*win_amd64*.whl \ |
| 208 | + "*.data/scripts/ggsql-jupyter.exe" -d /tmp/extract |
| 209 | + mv /tmp/extract/ggsql-jupyter.exe binaries/ggsql-jupyter-windows-x64.exe |
| 210 | + rm -rf /tmp/extract |
| 211 | +
|
| 212 | + chmod +x binaries/ggsql-jupyter-* |
| 213 | + ls -lh binaries/ |
| 214 | +
|
| 215 | + - name: Upload to GitHub Release |
| 216 | + uses: softprops/action-gh-release@v2 |
| 217 | + with: |
| 218 | + files: binaries/* |
0 commit comments