CI #52
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: CI | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- 'v*' | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: boolean | |
description: 'Run the build with debug logging enabled' | |
required: false | |
default: false | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
rust: [stable] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ matrix.rust }} | |
override: true | |
components: rustfmt, clippy | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --verbose | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --verbose | |
- name: Run clippy | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: -- -D warnings | |
# - name: Check formatting | |
# run: | | |
# cargo clean && rm -rf rpc/src/generated/*.rs && cargo fmt -- --check $(find . -name '*.rs' -type f | grep -v "/generated/") | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ runner.os }}-build | |
path: target/release/tappd-simulator* | |
- name: Debug log | |
if: ${{ github.event.inputs.debug_enabled == 'true' }} | |
run: | | |
echo "Debug logging enabled" | |
# 在这里添加您想要的任何额外的调试命令 | |
cargo --version | |
rustc --version | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Download all artifacts | |
uses: actions/download-artifact@v2 | |
- name: Calculate MD5 checksums | |
run: | | |
for artifact in *-build/*; do | |
md5sum "$artifact" >> checksums.md5 | |
done | |
- name: Upload Release Assets | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./checksums.md5 | |
asset_name: checksums.md5 | |
asset_content_type: text/plain | |
- name: Upload Binaries to Release | |
uses: AButler/upload-release-assets@v2.0 | |
with: | |
files: '*-build/*' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
release-tag: ${{ github.ref }} | |
- name: Debug log | |
if: ${{ github.event.inputs.debug_enabled == 'true' }} | |
shell: bash | |
run: | | |
echo "Debug logging enabled" | |
cargo --version | |
rustc --version | |
echo "Files being checked for formatting:" | |
find . -name '*.rs' -type f \ | |
! -path "./target/*" \ | |
! -path "*/generated/*" | |
echo "Rust edition in Cargo.toml:" | |
grep "edition" Cargo.toml | |