Automate publishing Rust build artifacts for GitHub releases through GitHub Actions.
This action can work under the conditions of creating release, pushing tag and specifying release.
Github release name (default from release action or tag action) Can not be specified, if you used release/tag action.
Required rust target. now only support
- x86_64_apple-darwin
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-gnu
Path to directory containing Cargo.toml (defaults to project root)
Relative path of script to run before building
Relative path of script to run after building
the project name (default repository name)
The build artifact name (default <name>
-<archive_suffix>
)
List of extra files to include in build Example: README.md LISENSE
This name is the suffix of the build artifact. (default to rust_target)
List of archive types to publish the binaries with, default "zip", supports zip and all tar formats
cargo build
options, more info see cargo build --help
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 }}