-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (99 loc) · 3.63 KB
/
Copy pathgo-bindings.yml
File metadata and controls
115 lines (99 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Go bindings
on:
workflow_dispatch:
create:
permissions:
contents: write
jobs:
build-extensions:
name: Build Go native extension (${{ matrix.name }})
if: github.event_name != 'create' || github.event.ref_type == 'tag'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x64-gnu
os: ubuntu-22.04
native-library: target/release/libw2v_bert_uk.so
- name: macos-arm64
os: macos-latest
native-library: target/release/libw2v_bert_uk.dylib
- name: windows-x64-msvc
os: windows-latest
native-library: target/release/w2v_bert_uk.dll
import-library: target/release/w2v_bert_uk.dll.lib
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Set up MSVC shell
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Build Go native extension
run: cargo build --release --no-default-features --features go,ort-dynamic --lib
- name: Prepare Go cgo smoke test
shell: pwsh
run: |
$nativeLibrary = "${{ matrix.native-library }}"
if (!(Test-Path $nativeLibrary)) {
throw "Native library was not produced: $nativeLibrary"
}
if (!(Test-Path "c/w2v_bert_uk.h")) {
throw "Generated C header was not produced"
}
New-Item -ItemType Directory -Force -Path native | Out-Null
Copy-Item $nativeLibrary native/
$importLibrary = "${{ matrix.import-library }}"
if ($importLibrary -and (Test-Path $importLibrary)) {
Copy-Item $importLibrary native/
}
- name: Compile Go bindings
if: runner.os != 'Windows'
run: go test ./go
- name: Package Go native extension
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path package/native | Out-Null
New-Item -ItemType Directory -Force -Path package/c | Out-Null
New-Item -ItemType Directory -Force -Path package/go | Out-Null
New-Item -ItemType Directory -Force -Path package/examples | Out-Null
Copy-Item native/* package/native/
Copy-Item c/w2v_bert_uk.h package/c/
Copy-Item go.mod package/
Copy-Item go/*.go package/go/
Copy-Item examples/transcribe.go package/examples/
Compress-Archive -Path package/* -DestinationPath "go-${{ matrix.name }}.zip" -Force
- name: Upload Go native extension
uses: actions/upload-artifact@v4
with:
name: go-${{ matrix.name }}
path: go-${{ matrix.name }}.zip
if-no-files-found: error
publish-release:
name: Upload Go native extensions to release
needs: build-extensions
if: >-
always() &&
!cancelled() &&
!failure() &&
(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'create' && github.event.ref_type == 'tag'))
runs-on: ubuntu-22.04
steps:
- name: Download Go native extensions
uses: actions/download-artifact@v4
with:
pattern: go-*
path: artifacts
merge-multiple: true
- name: Upload Go native extensions to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event_name == 'create' && github.event.ref || github.ref_name }}
files: artifacts/go-*.zip
fail_on_unmatched_files: true