|
17 | 17 | - name: Install CMake |
18 | 18 | run: brew install cmake |
19 | 19 |
|
| 20 | + - name: Setup Python for HuggingFace |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: '3.11' |
| 24 | + |
| 25 | + - name: Install HuggingFace CLI |
| 26 | + run: pip install huggingface_hub |
| 27 | + |
| 28 | + - name: Download test model from HuggingFace |
| 29 | + run: | |
| 30 | + mkdir -p models |
| 31 | + huggingface-cli download mlx-community/Qwen1.5-0.5B-Chat-4bit --local-dir models/Qwen1.5-0.5B-Chat-4bit |
| 32 | + echo "Model files:" |
| 33 | + ls -la models/Qwen1.5-0.5B-Chat-4bit/ |
| 34 | +
|
20 | 35 | - name: Build native stub library |
21 | 36 | run: | |
22 | 37 | cmake -S native -B native/build -DCMAKE_BUILD_TYPE=Release |
|
47 | 62 |
|
48 | 63 | - name: Run tests |
49 | 64 | run: dotnet test MLXSharp.sln --configuration Release --no-build --logger "trx;LogFileName=TestResults.trx" --results-directory artifacts/test-results |
| 65 | + env: |
| 66 | + MLXSHARP_MODEL_PATH: ${{ github.workspace }}/models/Qwen1.5-0.5B-Chat-4bit |
50 | 67 |
|
51 | 68 | - name: Prepare artifact folders |
52 | 69 | run: | |
|
55 | 72 | mkdir -p artifacts/native |
56 | 73 | cp src/MLXSharp.Native/runtimes/osx-arm64/native/libmlxsharp.dylib artifacts/native/ |
57 | 74 |
|
58 | | - - name: Pack library |
| 75 | + - name: Pack MLXSharp library |
59 | 76 | run: dotnet pack src/MLXSharp/MLXSharp.csproj --configuration Release --no-build --output artifacts/packages |
60 | 77 |
|
| 78 | + - name: Pack MLXSharp.SemanticKernel library |
| 79 | + run: dotnet pack src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj --configuration Release --no-build --output artifacts/packages |
| 80 | + |
61 | 81 | - name: Verify package contains native libraries |
62 | 82 | run: | |
63 | 83 | echo "Checking package contents..." |
@@ -88,3 +108,89 @@ jobs: |
88 | 108 | with: |
89 | 109 | name: test-results |
90 | 110 | path: artifacts/test-results |
| 111 | + |
| 112 | + release: |
| 113 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 114 | + needs: build-test |
| 115 | + runs-on: ubuntu-latest |
| 116 | + permissions: |
| 117 | + contents: write |
| 118 | + steps: |
| 119 | + - name: Checkout repository |
| 120 | + uses: actions/checkout@v4 |
| 121 | + |
| 122 | + - name: Extract version from Directory.Build.props |
| 123 | + id: version |
| 124 | + run: | |
| 125 | + VERSION=$(grep -oP '<Version>\K[^<]+' Directory.Build.props) |
| 126 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 127 | + echo "Extracted version: $VERSION" |
| 128 | +
|
| 129 | + # - name: Check if tag exists |
| 130 | + # id: check_tag |
| 131 | + # run: | |
| 132 | + # if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.version.outputs.version }}"; then |
| 133 | + # echo "exists=true" >> $GITHUB_OUTPUT |
| 134 | + # echo "Tag v${{ steps.version.outputs.version }} already exists" |
| 135 | + # else |
| 136 | + # echo "exists=false" >> $GITHUB_OUTPUT |
| 137 | + # echo "Tag v${{ steps.version.outputs.version }} does not exist" |
| 138 | + # fi |
| 139 | + |
| 140 | + # - name: Download package artifacts |
| 141 | + # if: steps.check_tag.outputs.exists == 'false' |
| 142 | + # uses: actions/download-artifact@v4 |
| 143 | + # with: |
| 144 | + # name: packages |
| 145 | + # path: artifacts/packages |
| 146 | + |
| 147 | + # - name: Publish to NuGet |
| 148 | + # if: steps.check_tag.outputs.exists == 'false' |
| 149 | + # run: | |
| 150 | + # for package in artifacts/packages/*.nupkg; do |
| 151 | + # echo "Publishing $package..." |
| 152 | + # dotnet nuget push "$package" \ |
| 153 | + # --api-key ${{ secrets.NUGET_API_KEY }} \ |
| 154 | + # --source https://api.nuget.org/v3/index.json \ |
| 155 | + # --skip-duplicate || true |
| 156 | + # done |
| 157 | + |
| 158 | + # - name: Create Git tag |
| 159 | + # if: steps.check_tag.outputs.exists == 'false' |
| 160 | + # run: | |
| 161 | + # git config user.name "github-actions[bot]" |
| 162 | + # git config user.email "github-actions[bot]@users.noreply.github.com" |
| 163 | + # git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" |
| 164 | + # git push origin "v${{ steps.version.outputs.version }}" |
| 165 | + |
| 166 | + # - name: Generate release notes |
| 167 | + # if: steps.check_tag.outputs.exists == 'false' |
| 168 | + # id: release_notes |
| 169 | + # run: | |
| 170 | + # PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "") |
| 171 | + # if [ -z "$PREVIOUS_TAG" ]; then |
| 172 | + # COMMITS=$(git log --pretty=format:"- %s (%h)" --reverse) |
| 173 | + # else |
| 174 | + # COMMITS=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --reverse) |
| 175 | + # fi |
| 176 | + |
| 177 | + # echo "## What's Changed" > release_notes.md |
| 178 | + # echo "" >> release_notes.md |
| 179 | + # echo "$COMMITS" >> release_notes.md |
| 180 | + # echo "" >> release_notes.md |
| 181 | + # echo "## NuGet Packages" >> release_notes.md |
| 182 | + # echo "- [MLXSharp v${{ steps.version.outputs.version }}](https://www.nuget.org/packages/MLXSharp/${{ steps.version.outputs.version }})" >> release_notes.md |
| 183 | + # echo "- [MLXSharp.SemanticKernel v${{ steps.version.outputs.version }}](https://www.nuget.org/packages/MLXSharp.SemanticKernel/${{ steps.version.outputs.version }})" >> release_notes.md |
| 184 | + |
| 185 | + # cat release_notes.md |
| 186 | + |
| 187 | + # - name: Create GitHub Release |
| 188 | + # if: steps.check_tag.outputs.exists == 'false' |
| 189 | + # uses: softprops/action-gh-release@v1 |
| 190 | + # with: |
| 191 | + # tag_name: v${{ steps.version.outputs.version }} |
| 192 | + # name: Release v${{ steps.version.outputs.version }} |
| 193 | + # body_path: release_notes.md |
| 194 | + # files: artifacts/packages/* |
| 195 | + # env: |
| 196 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments