json输出保持map有序。更新协议 #29
Workflow file for this run
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: # @see https://help.github.com/en/articles/events-that-trigger-workflows#webhook-events | |
push: | |
branches: # Array of patterns that match refs/heads | |
- main # Push events on master branch | |
tags: | |
- "v*" | |
pull_request: | |
branches: [main] | |
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] | |
toolchain: [stable] | |
target: [x86_64-unknown-linux-gnu] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
target: ${{ matrix.target }} | |
override: true | |
default: true | |
components: "rustfmt, clippy, cargo, rust-docs" | |
- name: Format and lint | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
shell: bash | |
run: | | |
cargo fmt --all -- --check | |
cargo clippy | |
- name: Cache prebuilt and cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
~/prebuilt | |
!~/prebuilt/exclude | |
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} | |
# - name: Generate coverage | |
# if: ${{ matrix.os == 'ubuntu-latest' && !startsWith(github.ref, 'refs/tags/') }} | |
# shell: bash | |
# run: | | |
# cargo install cargo-tarpaulin; | |
# cargo tarpaulin -v --all-features --timeout 120 --out Xml; | |
# - name: Uploaded code coverage | |
# if: ${{ matrix.os == 'ubuntu-latest' && !startsWith(github.ref, 'refs/tags/') }} | |
# uses: codecov/codecov-action@v1 | |
# with: | |
# # token: ${{secrets.CODECOV_TOKEN}} # not required for public repos | |
# fail_ci_if_error: true | |
# gcov_path_exclude: /.cargo,/usr/lib,~/.cargo | |
linux_build: # job id, can be any string | |
# Job name is Build And Publish | |
name: Linux Build | |
# This job runs on Linux | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
rust: [stable] | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- aarch64-unknown-linux-musl | |
- x86_64-unknown-linux-musl | |
- aarch64-linux-android | |
- x86_64-linux-android | |
# see https://github.com/rust-embedded/cross | |
# Github action is run under a docker pod but cross need docker service | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
target: ${{ matrix.target }} | |
override: true | |
default: true | |
components: "rustfmt, clippy, cargo, rust-docs" | |
- name: Cargo Release build | |
uses: actions-rs/cargo@v1 | |
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} | |
with: | |
use-cross: false | |
command: build | |
args: --target ${{ matrix.target }} --release --all-features | |
- name: Cross Release build | |
if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }} | |
shell: bash | |
run: | | |
NEED_RETRY=0 | |
cargo install cross xargo | |
cross build --target ${{ matrix.target }} --release --all-features || NEED_RETRY=1 | |
if [[ $NEED_RETRY -ne 0 ]]; then | |
cargo install cross --git https://github.com/cross-rs/cross | |
fi | |
cross build --target ${{ matrix.target }} --release --all-features | |
- name: Debug build & test | |
uses: actions-rs/cargo@v1 | |
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} | |
with: | |
command: test | |
args: --all-features | |
env: | |
RUSTFLAGS: "-C link-dead-code" | |
- name: Cache prebuilt and cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
~/prebuilt | |
!~/prebuilt/exclude | |
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p "target/${{ matrix.target }}/release" | |
cd "target/${{ matrix.target }}/release/" | |
mkdir -p bin; | |
if [[ -e xresloader-dump-bin ]]; then | |
cp -f xresloader-dump-bin bin/xresloader-dump-bin; | |
else | |
cp -f xresloader-dump-bin* bin/; | |
fi | |
tar -zcvf ${{ matrix.target }}.tar.gz bin ; | |
cd ../../..; | |
mv -f "target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz" ./; | |
- uses: xresloader/upload-to-github-release@v1 | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "*.tar.gz" | |
tags: true | |
draft: true | |
overwrite: true | |
macos_build: # job id, can be any string | |
# Job name is Build And Publish | |
name: macOS Build | |
# This job runs on Linux | |
strategy: | |
matrix: | |
os: [macOS-latest] | |
rust: [stable] | |
target: [x86_64-apple-darwin] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
target: ${{ matrix.target }} | |
override: true | |
default: true | |
components: "rustfmt, clippy, cargo, rust-docs" | |
- name: Cargo Release build | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: false | |
command: build | |
args: --target ${{ matrix.target }} --release --all-features | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p "target/${{ matrix.target }}/release" | |
cd "target/${{ matrix.target }}/release/"; | |
mkdir -p bin; | |
if [[ -e xresloader-dump-bin ]]; then | |
cp -f xresloader-dump-bin bin/xresloader-dump-bin; | |
else | |
cp -f xresloader-dump-bin* bin/; | |
fi | |
tar -zcvf ${{ matrix.target }}.tar.gz bin ; | |
cd ../../..; | |
mv -f "target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz" ./; | |
- name: Run tests | |
run: | | |
cargo test --release --verbose --target ${{ matrix.target }} | |
- uses: xresloader/upload-to-github-release@v1 | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "*.tar.gz" | |
tags: true | |
draft: true | |
overwrite: true | |
windows_build: # job id, can be any string | |
# Job name is Build And Publish | |
name: Windows Build | |
# This job runs on Linux | |
strategy: | |
matrix: | |
os: [windows-latest] | |
rust: [stable] | |
target: [x86_64-pc-windows-msvc] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
target: ${{ matrix.target }} | |
override: true | |
default: 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 --all-features | |
- name: Cross 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 --all-features | |
- name: Package | |
shell: pwsh | |
run: | | |
cd "./target/${{ matrix.target }}/release/" | |
mkdir bin | |
Copy-Item -Force xresloader-dump-bin.exe bin/ | |
if ( Test-Path "${{ matrix.target }}.zip" ) { Remove-Item -Force "${{ matrix.target }}.zip" } | |
Compress-Archive -DestinationPath "${{ matrix.target }}.zip" -Path bin | |
Get-ChildItem | |
Get-ChildItem -Recurse bin | |
Copy-Item -Force "${{ matrix.target }}.zip" ../../../ | |
cd ../../../ | |
- name: Run tests | |
shell: pwsh | |
run: | | |
cargo test --release --verbose --target ${{ matrix.target }} | |
- uses: xresloader/upload-to-github-release@v1 | |
if: ${{ github.ref_type == 'tag' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "*.zip" | |
tags: true | |
draft: true | |
overwrite: true |