|
| 1 | +name: CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + branches: [main, master] |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Setup tools with mise |
| 17 | + uses: jdx/mise-action@v2 |
| 18 | + with: |
| 19 | + install: true |
| 20 | + cache: true |
| 21 | + |
| 22 | + - name: Setup project |
| 23 | + run: just ci-setup |
| 24 | + |
| 25 | + - name: Run all checks |
| 26 | + run: just check |
| 27 | + |
| 28 | + test: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: lint |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Setup tools with mise |
| 35 | + uses: jdx/mise-action@v2 |
| 36 | + with: |
| 37 | + install: true |
| 38 | + cache: true |
| 39 | + |
| 40 | + - name: Setup project |
| 41 | + run: just ci-setup |
| 42 | + |
| 43 | + - name: Run unit tests |
| 44 | + run: just test-unit |
| 45 | + |
| 46 | + build-vendor: |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + include: |
| 50 | + - os: ubuntu-latest |
| 51 | + platform: linux-x64 |
| 52 | + - os: ubuntu-latest |
| 53 | + platform: linux-arm64 |
| 54 | + - os: macos-latest |
| 55 | + platform: darwin-arm64 |
| 56 | + - os: macos-13 |
| 57 | + platform: darwin-x64 |
| 58 | + - os: windows-latest |
| 59 | + platform: win32-x64 |
| 60 | + runs-on: ${{ matrix.os }} |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: Setup tools with mise |
| 65 | + uses: jdx/mise-action@v2 |
| 66 | + with: |
| 67 | + install: true |
| 68 | + cache: true |
| 69 | + |
| 70 | + - name: Build vendor bundle |
| 71 | + shell: bash |
| 72 | + run: just ci-build-vendor ${{ matrix.platform }} |
| 73 | + |
| 74 | + - name: Upload vendor artifact |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: vendor-${{ matrix.platform }} |
| 78 | + path: mlnative/_vendor/${{ matrix.platform }}/ |
| 79 | + retention-days: 1 |
| 80 | + |
| 81 | + build-package: |
| 82 | + needs: [test, build-vendor] |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Download all vendor artifacts |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + with: |
| 90 | + path: mlnative/_vendor/ |
| 91 | + pattern: vendor-* |
| 92 | + merge-multiple: false |
| 93 | + |
| 94 | + - name: Organize vendor directories |
| 95 | + run: | |
| 96 | + for dir in mlnative/_vendor/vendor-*; do |
| 97 | + platform=$(basename "$dir" | sed 's/vendor-//') |
| 98 | + mv "$dir" "mlnative/_vendor/$platform" |
| 99 | + done |
| 100 | + |
| 101 | + - name: Setup tools with mise |
| 102 | + uses: jdx/mise-action@v2 |
| 103 | + with: |
| 104 | + install: true |
| 105 | + cache: true |
| 106 | + |
| 107 | + - name: Build package |
| 108 | + run: just ci-build |
| 109 | + |
| 110 | + - name: Upload package artifacts |
| 111 | + uses: actions/upload-artifact@v4 |
| 112 | + with: |
| 113 | + name: dist |
| 114 | + path: dist/ |
| 115 | + retention-days: 5 |
| 116 | + |
| 117 | + publish-testpypi: |
| 118 | + needs: build-package |
| 119 | + runs-on: ubuntu-latest |
| 120 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 121 | + environment: |
| 122 | + name: testpypi |
| 123 | + url: https://test.pypi.org/p/mlnative |
| 124 | + permissions: |
| 125 | + id-token: write |
| 126 | + steps: |
| 127 | + - name: Download package artifacts |
| 128 | + uses: actions/download-artifact@v4 |
| 129 | + with: |
| 130 | + name: dist |
| 131 | + path: dist/ |
| 132 | + |
| 133 | + - name: Publish to TestPyPI |
| 134 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 135 | + with: |
| 136 | + repository-url: https://test.pypi.org/legacy/ |
| 137 | + |
| 138 | + publish-pypi: |
| 139 | + needs: [build-package, publish-testpypi] |
| 140 | + runs-on: ubuntu-latest |
| 141 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 142 | + environment: |
| 143 | + name: pypi |
| 144 | + url: https://pypi.org/p/mlnative |
| 145 | + permissions: |
| 146 | + id-token: write |
| 147 | + steps: |
| 148 | + - name: Download package artifacts |
| 149 | + uses: actions/download-artifact@v4 |
| 150 | + with: |
| 151 | + name: dist |
| 152 | + path: dist/ |
| 153 | + |
| 154 | + - name: Publish to PyPI |
| 155 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments