-
Notifications
You must be signed in to change notification settings - Fork 11
79 lines (68 loc) · 2.53 KB
/
build-on-windows.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
name: "Build On Windows"
on: [push]
jobs:
build: # job id, can be any string
# Job name is Build And Publish
name: Build
# This job runs on Linux
strategy:
matrix:
os: [windows-latest]
rust: [stable]
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc]
# x86_64-pc-windows-gnu, i686-pc-windows-gnu,
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache cargo modules
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
default: true
override: true
components: "rustfmt, clippy, cargo, rust-docs"
- name: Cargo Release build
uses: actions-rs/cargo@v1
if: ${{ matrix.target != 'x86_64-pc-windows-gnu' }}
with:
use-cross: false
command: build
args: --target ${{ matrix.target }} --release --jobs 2 --verbose
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --release --verbose --target ${{ matrix.target }} --bin wxwork_robotd
- name: Prepare package
shell: pwsh
if: ${{ contains(github.ref, 'refs/tags/') }}
run: |
cd "$ENV:GITHUB_WORKSPACE/target/${{ matrix.target }}/release/"
if ( Test-Path "tools" ) { Remove-Item -Recurse -Force "tools" }
if ( Test-Path "etc" ) { Remove-Item -Recurse -Force "etc" }
New-Item -Force -ItemType Directory "bin"
Copy-Item -Force -Recurse "../../../tools" "./"
Copy-Item -Force -Recurse "../../../etc" "./"
Copy-Item -Force "wxwork_robotd.exe" "bin/"
if ( Test-Path "${{ matrix.target }}.zip" ) { Remove-Item -Force "${{ matrix.target }}.zip" }
Compress-Archive -DestinationPath "${{ matrix.target }}.zip" -Path etc,bin,tools
cd "$ENV:GITHUB_WORKSPACE"
- uses: xresloader/upload-to-github-release@master
if: ${{ contains(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "target/${{ matrix.target }}/release/${{ matrix.target }}.zip"
tags: true
draft: false
prerelease: false
overwrite: true