Switch toolchain #39
This file contains 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: "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: [ubuntu-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: Install build dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install --assume-yes nasm clang ninja-build llvm | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
target: ${{ matrix.target }} | |
components: "rustfmt, clippy, cargo, rust-docs" | |
- name: Install cargo-xwin and bindgen-cli | |
run: | | |
cargo install cargo-xwin bindgen-cli | |
- name: cargo xwin build for `${{ matrix.target }}` | |
run: cargo xwin build --release --target ${{ matrix.target }} | |
- name: cargo xwin build for `${{ matrix.target }}` | |
run: cargo xwin test --release --verbose --target ${{ matrix.target }} --bin ddns-cli | |
- name: Prepare package | |
shell: pwsh | |
if: ${{ contains(github.ref, 'refs/tags/') }} | |
run: | | |
cd "$ENV:GITHUB_WORKSPACE/target/${{ matrix.target }}/release/" ; | |
New-Item -Force -ItemType Directory bin ; | |
Copy-Item -Force ddns-cli.exe bin/ ; | |
if ( Test-Path "${{ matrix.target }}.zip" ) { Remove-Item -Force "${{ matrix.target }}.zip" } | |
Compress-Archive -DestinationPath "${{ matrix.target }}.zip" -Path bin | |
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 |