Skip to content

打印日志类型更新 #3

打印日志类型更新

打印日志类型更新 #3

Workflow file for this run

name: Rust Build and Release
on:
push:
tags:
- "v*" # 仅在推送 v 开头的 tag 时触发
permissions:
contents: write
env:
# !!! 请在这里修改你的 Rust 项目名称 (即 Cargo.toml 中的 name 字段) !!!
BINARY_NAME: transfer
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: linux-amd64
# Linux 编译产物没有后缀
bin_suffix: ""
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: windows-amd64
# Windows 编译产物有 .exe 后缀
bin_suffix: ".exe"
# macOS (Intel) - 如果需要 Apple Silicon,可增加 macos-14 和 aarch64 目标
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: macos-amd64
bin_suffix: ""
steps:
- name: Checkout code
uses: actions/checkout@v4
# 安装 Rust 工具链 (社区推荐方式)
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# (可选) 缓存 Cargo 依赖,加速构建
- name: Rust Cache
uses: swatinem/rust-cache@v2
# 编译 Release 版本
- name: Build
run: cargo build --release --target ${{ matrix.target }}
# 准备产物:重命名文件以便上传
- name: Prepare artifact
shell: bash
run: |
mkdir -p build_assets
# 将原始二进制文件复制并重命名,例如:my-rust-app-linux-amd64
cp target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.bin_suffix }} build_assets/${{ env.BINARY_NAME }}-${{ matrix.artifact_name }}${{ matrix.bin_suffix }}
# 上传处理好的文件到 GitHub Actions 临时存储
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}-${{ matrix.artifact_name }}
path: build_assets/*
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release_assets
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: release_assets/*
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}