Giter VIP home page Giter VIP logo

rust-build.action's Introduction

Rust Release Binary Github Action

.github/workflows/build.yml Lint

Automate publishing Rust build artifacts for GitHub releases through GitHub Actions (Based on go-release.action)

For an example/template repo see rust-build.test

This action will only work when you release a project as it uploads the artifacts to the release.

Environment variables

GITHUB_TOKEN      # Must be set to ${{ secrets.GITHUB_TOKEN }} - Allows uploading of artifacts to release
RUSTTARGET        # The rust target triple, see README for supported triples
EXTRA_FILES       # Space separated list of extra files to include in final output
SRC_DIR           # Relative path to the src dir (directory with Cargo.toml in) from root of project
ARCHIVE_TYPES     # Type(s) of archive(s) to create, e.g. "zip" (default) or "zip tar.gz"; supports: (zip, tar.[gz|bz2|xz|zst])
ARCHIVE_NAME      # Full name of archive to upload (you must specify file extension and change this if building multiple targets)
PRE_BUILD         # Path to script to run before build e.g. "pre.sh"
POST_BUILD        # Path to script to run after build e.g. "post.sh"
MINIFY            # If set to "true", the resulting binary will be stripped and compressed by UPX. ("false" by default)
TOOLCHAIN_VERSION # The rust toolchain version to use (see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification)
UPLOAD_MODE       # What method to use to upload compiled binaries, supported values: (release, none), default: release

Examples

Build windows and linux and upload as zip

# .github/workflows/release.yml

on:
  release:
    types: [created]

jobs:
  release:
    name: release ${{ matrix.target }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-musl]
    steps:
      - uses: actions/checkout@master
      - name: Compile and release
        uses: rust-build/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          RUSTTARGET: ${{ matrix.target }}
          EXTRA_FILES: "README.md LICENSE"

Build windows, linux and mac with native zip types

Will build native binaries for windows, linux and mac. Windows will upload as .zip, linux as .tar.gz, .tar.xz and .tar.zst, and mac as .zip.

# .github/workflows/release.yml

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/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          RUSTTARGET: ${{ matrix.target }}
          ARCHIVE_TYPES: ${{ matrix.archive }}

Upload output as an artifact (or use with other steps)

# .github/workflows/build.yml
name: Build

on:
  push:
    branches: [main]

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Compile
        id: compile
        uses: rust-build/[email protected]
        with:
          RUSTTARGET: x86_64-unknown-linux-musl
          UPLOAD_MODE: none
      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: Binary
          path: |
            ${{ steps.compile.outputs.BUILT_ARCHIVE }}
            ${{ steps.compile.outputs.BUILT_CHECKSUM }}

Many target triples do not work, I am working on adding more support

Supported targets

  • x86_64-pc-windows-gnu
  • x86_64-unknown-linux-musl
  • wasm32-wasi
  • x86_64-apple-darwin

rust-build.action's People

Contributors

douile avatar gwbres avatar hugues31 avatar ihaiker avatar kent-williams avatar kolemikko avatar mortenlohne avatar orium avatar rimathia avatar sadikkuzu avatar suhlig avatar tecknicaltom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.