自动发布 Rust 构建知道到 Github release。此 action 可以直接 release、tag 和指定 release 三种模式。
指定制品上传 release,默认情况下可以从 release 模式的获取,或者从 tag 模式获取相应的 release name.
Required rust target 现在仅仅支持:
- x86_64_apple-darwin
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-gnu
源文件路径,该路径下必须包含 Cargo.toml 文件。(默认情况为当前项目根目录)
构建前需要执行的脚本
构建后需要执行的脚本
项目名称,默认为 github repository name.
release 制品名称,默认为:<name>
-<archive_suffix>
制品打包需要额外打入的文件列表 Example: README.md LISENSE
制品文件名后半截,例如可以使用 derawin-x86_64
替换 x86_64_apple-darwin
),默认为 rust_target
制品文件压缩类型,默认: zip
, 支持 tar 的所有压缩类型
cargo build
额外构建参数
name: release
on:
release:
types: [created]
jobs:
release:
name: publish ${{ matrix.name }}
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-pc-windows-gnu
suffix: windows-x86_64
archive: zip
name: x86_64-pc-windows-gnu
- target: x86_64-unknown-linux-gnu
suffix: linux-x86_64
archive: tar.xz
name: x86_64-unknown-linux-gnu
- target: x86_64-apple-darwin
suffix: darwin-x86_64
archive: tar.gz
name: x86_64-apple-darwin
runs-on: ubuntu-latest
steps:
- name: Clone test repository
uses: actions/checkout@v2
- uses: xhaiker/[email protected]
name: build ${{ matrix.name }}
with:
rust_target: ${{ matrix.target }}
archive_suffix: ${{ matrix.suffix }}
archive_types: ${{ matrix.archive }}
extra_files: "README.md README_zh.md LICENSE"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: release
on:
push:
tags:
- "v*"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
publish:
name: publish ${{ matrix.name }}
needs:
- release
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-pc-windows-gnu
suffix: windows-x86_64
archive: zip
name: x86_64-pc-windows-gnu
- target: x86_64-unknown-linux-gnu
suffix: linux-x86_64
archive: tar.xz
name: x86_64-unknown-linux-gnu
- target: x86_64-apple-darwin
suffix: darwin-x86_64
archive: tar.gz
name: x86_64-apple-darwin
runs-on: ubuntu-latest
steps:
- name: Clone test repository
uses: actions/checkout@v2
- uses: xhaiker/[email protected]
name: build ${{ matrix.name }}
with:
release: ${{ github.ref_name }}
rust_target: ${{ matrix.target }}
archive_suffix: ${{ matrix.suffix }}
archive_types: ${{ matrix.archive }}
extra_files: "README.md README_zh.md LICENSE"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}