-
Notifications
You must be signed in to change notification settings - Fork 3
172 lines (146 loc) · 4.81 KB
/
rust.yml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Rust
on:
push:
branches: [ "main" ]
tags: "v*"
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_name: kari
artifact_name: kari-linux-x64
- os: windows-latest
target: x86_64-pc-windows-msvc # Changed from gnu to msvc
binary_name: kari.exe
artifact_name: kari-windows-x64
- os: macos-latest
target: aarch64-apple-darwin
binary_name: kari
artifact_name: kari-macos-arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive' # Add this to fetch submodules
- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
gcc \
libssl-dev \
pkg-config \
libclang-dev
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
run: |
choco install visualstudio2019buildtools
choco install visualstudio2019-workload-vctools
rustup default nightly-x86_64-pc-windows-msvc
- name: Setup Windows environment
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$ReleasePath = "target\${{ matrix.target }}\release"
New-Item -ItemType Directory -Force -Path $ReleasePath
$env:Path += ";C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\x64"
# Copy DLLs after build completes
if (Test-Path "C:\Windows\System32\vcruntime140.dll") {
Copy-Item "C:\Windows\System32\vcruntime140.dll" -Destination $ReleasePath
}
if (Test-Path "C:\Windows\System32\msvcp140.dll") {
Copy-Item "C:\Windows\System32\msvcp140.dll" -Destination $ReleasePath
}
- name: Install macOS dependencies
if: matrix.os == 'macos-latest'
run: |
brew install openssl@3
brew install pkg-config
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Build
run: cargo build --release --target ${{ matrix.target }} --verbose
env:
OPENSSL_DIR: /usr/local/opt/openssl@3
# - name: Test
# run: cargo test --target ${{ matrix.target }} --verbose
# env:
# OPENSSL_DIR: /usr/local/opt/openssl@3
- name: Debug binary location
if: matrix.os == 'windows-latest'
run: |
dir target\${{ matrix.target }}\release\
shell: cmd
- name: Debug binary location
if: matrix.os != 'windows-latest'
run: ls -la target/${{ matrix.target }}/release/
- name: Compress artifacts (Linux/MacOS)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czf ${{ matrix.artifact_name }}.tar.gz ${{ matrix.binary_name }}
- name: Compress artifacts (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$ReleasePath = "target\${{ matrix.target }}\release"
Set-Location $ReleasePath
$Files = @()
if (Test-Path "${{ matrix.binary_name }}") {
$Files += "${{ matrix.binary_name }}"
}
if (Test-Path "vcruntime140.dll") {
$Files += "vcruntime140.dll"
}
if (Test-Path "msvcp140.dll") {
$Files += "msvcp140.dll"
}
Compress-Archive -Path $Files -DestinationPath ${{ matrix.artifact_name }}.zip -Force
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}.*
retention-days: 5
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
pattern: kari-*
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/kari-linux-x64.tar.gz
artifacts/kari-windows-x64.zip
artifacts/kari-macos-arm64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}