Skip to content

Commit

Permalink
add: github action release.
Browse files Browse the repository at this point in the history
  • Loading branch information
auula committed Jul 26, 2024
1 parent 8081776 commit 2353a6c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 53 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .github/workflows/release.yml
name: Rust Release

on:
release:
types: [created]

jobs:
release:
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz tar.xz tar.zst
- target: x86_64-apple-darwin
archive: zip
steps:
- uses: actions/checkout@master
- name: Compile and release
uses: rust-build/rust-build.action@v1.4.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
75 changes: 22 additions & 53 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,40 @@
name: Rust CI and Release
name: Rust CI

# 当推送到 main 或 dev 分支时触发 Rust CI 工作流
on:
push:
branches:
- main
- dev
tags:
- v[0-9]+.*
- dev # 在 push 到 main 或 dev 分支时触发
pull_request:
branches:
- main
- dev

- dev # 在拉取请求到 main 或 dev 分支时触发

env:
CARGO_TERM_COLOR: always

jobs:
# Rust CI 工作流
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Cargo Tarpaulin
run: cargo install cargo-tarpaulin
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run cargo-tarpaulin
run: cargo tarpaulin --out Xml
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run cargo-audit
run: cargo audit
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

# Release 工作流
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

upload-assets:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: typikon
tar: unix
zip: windows
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Cargo Tarpaulin
run: cargo install cargo-tarpaulin
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run cargo-tarpaulin
run: cargo tarpaulin --out Xml
- name: Run cargo-audit
run: cargo install cargo-audit && cargo-audit audit
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 2353a6c

Please sign in to comment.