cicd #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| - os: windows-latest | |
| goos: windows | |
| goarch: amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Prepare dist | |
| shell: bash | |
| run: mkdir -p dist | |
| - name: Download ONNX Runtime (windows only) | |
| if: matrix.goos == 'windows' | |
| shell: pwsh | |
| run: | | |
| $ver="1.22.0" | |
| $url="https://github.com/microsoft/onnxruntime/releases/download/v$ver/onnxruntime-win-x64-$ver.zip" | |
| Invoke-WebRequest -Uri $url -OutFile ort.zip | |
| Expand-Archive ort.zip -DestinationPath ort | |
| $dll = Get-ChildItem -Recurse -Filter onnxruntime.dll -Path ort | Select-Object -First 1 | |
| if (-not $dll) { Write-Error "onnxruntime.dll not found in archive"; exit 1 } | |
| Copy-Item $dll.FullName dist\onnxruntime.dll | |
| - name: Build | |
| shell: bash | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 1 | |
| WINDOWS: ${{ matrix.goos == 'windows' && '1' || '0' }} | |
| run: | | |
| if [ "$GOOS" = "windows" ]; then | |
| make build-windows | |
| else | |
| make build-linux | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: | | |
| dist/hf_transformers_go-${{ matrix.goos }}-${{ matrix.goarch }}* | |
| dist/onnxruntime.dll | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: List artifacts | |
| run: ls -R dist | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| files: | | |
| dist/**/hf_transformers_go-linux-amd64 | |
| dist/**/hf_transformers_go-windows-amd64.exe | |
| dist/**/onnxruntime.dll | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |