All Projects → taiki-e → upload-rust-binary-action

taiki-e / upload-rust-binary-action

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
GitHub Action for building and uploading Rust binary to GitHub Releases.

Programming Languages

shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to upload-rust-binary-action

package-version-check-action
GitHub Actions to check package version before publish
Stars: ✭ 30 (-36.17%)
Mutual labels:  github-actions
django-github-digitalocean
Continuously Deploying Django to DigitalOcean with Docker and GitHub Actions
Stars: ✭ 45 (-4.26%)
Mutual labels:  github-actions
blackcater
Using Node.js to generate my Github profile readme automatically.
Stars: ✭ 84 (+78.72%)
Mutual labels:  github-actions
deploy-firebase
A GitHub Action to deploy to Firebase Hosting
Stars: ✭ 63 (+34.04%)
Mutual labels:  github-actions
action-ansible-playbook
⚙️ A GitHub Action for running Ansible playbooks
Stars: ✭ 133 (+182.98%)
Mutual labels:  github-actions
rspec-github
Formatter for RSpec to show errors in GitHub action annotations
Stars: ✭ 33 (-29.79%)
Mutual labels:  github-actions
Github-Android-Action
Android Github Action that builds Android project, runs unit tests and generates debug APK, builds for Github Actions hackathon
Stars: ✭ 29 (-38.3%)
Mutual labels:  github-actions
awscredswrap
awscredswrap uses temporary credentials for the specified iam role to set a shell environment variable or execute a command.
Stars: ✭ 15 (-68.09%)
Mutual labels:  github-actions
github-actions-all-in-one-project
Automatically add an issue or pull request to specific GitHub Project when you create them.
Stars: ✭ 27 (-42.55%)
Mutual labels:  github-actions
nextjs-github-pages
🚀 Deploy a Next.js app to Github Pages via Github Actions.
Stars: ✭ 89 (+89.36%)
Mutual labels:  github-actions
gitrivy
GitHub Issue + Trivy Action
Stars: ✭ 46 (-2.13%)
Mutual labels:  github-actions
translation-action
GitHub action that translates any text to any language supported by chosen provider.
Stars: ✭ 25 (-46.81%)
Mutual labels:  github-actions
gh fsync
🔄 GitHub action to sync files across repos in GitHub
Stars: ✭ 17 (-63.83%)
Mutual labels:  github-actions
100 Days Of Go
100 days of Go learning
Stars: ✭ 24 (-48.94%)
Mutual labels:  github-actions
setup-arduino-cli
GitHub Action to setup Arduino CLI
Stars: ✭ 59 (+25.53%)
Mutual labels:  github-actions
actions
GitHub Actions for R-hub
Stars: ✭ 18 (-61.7%)
Mutual labels:  github-actions
vidyabhandary
Self updating profile readme for github
Stars: ✭ 36 (-23.4%)
Mutual labels:  github-actions
webring
“วงแหวนเว็บ” แห่งนี้สร้างขึ้นเพื่อส่งเสริมให้ศิลปิน นักออกแบบ และนักพัฒนาชาวไทย สร้างเว็บไซต์ของตัวเองและแบ่งปันการเข้าชมซึ่งกันและกัน
Stars: ✭ 125 (+165.96%)
Mutual labels:  github-actions
pin-github-action
Pin your GitHub actions to a specific hash
Stars: ✭ 38 (-19.15%)
Mutual labels:  github-actions
github-deploy-actions
This action will auto deploy to target branch when it get triggered
Stars: ✭ 24 (-48.94%)
Mutual labels:  github-actions

upload-rust-binary-action

build status

GitHub Action for building and uploading Rust binary to GitHub Releases.

Usage

This action builds and uploads Rust binary that specified by bin option to GitHub Releases.

Currently, this action is basically intended to be used in combination with an action like create-gh-release-action that creates a GitHub release when a tag is pushed.

Inputs

Name Required Description Type Default
bin true Comma-separated list of binary names (non-extension portion of filename) to build and upload String
archive false Archive name (non-extension portion of filename) to be uploaded String $bin-$target
target false Target triple, default is host triple String (host triple)
features false Comma-separated list of cargo build features to enable String
tar false On which platform to distribute the .tar.gz file (all, unix, windows, or none) String unix
zip false On which platform to distribute the .zip file (all, unix, windows, or none) String windows
checksum false Comma-separated list of algorithms to be used for checksum (sha256, sha512, sha1, or md5) String
include false Comma-separated list of additional files to be included to the archive String
asset false Comma-separated list of additional files to be uploaded separately String
leading_dir false Whether to create the leading directory in the archive or not Boolean false
build_tool false Tool to build binaries (cargo or cross, see cross-compilation example for more) String

Example workflow: Basic usage

In this example, when a new tag is pushed, creating a new GitHub Release by using create-gh-release-action, then uploading Rust binary to the created GitHub Release.

An archive file with a name like $bin-$target.tar.gz will be uploaded to GitHub Release.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
          # Note that glob pattern is not supported yet.
          bin: ...
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

You can specify multiple binaries when the root manifest is a virtual manifest or specified binaries are in the same crate.

- uses: taiki-e/upload-rust-binary-action@v1
  with:
    # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
    # Note that glob pattern is not supported yet.
    bin: app1,app2
    # (optional) Archive name (non-extension portion of filename) to be uploaded.
    # [default value: $bin-$target]
    # [possible values: the following variables and any string]
    #   variables:
    #     - $bin    - Binary name (non-extension portion of filename).
    #     - $target - Target triple.
    #     - $tag    - Tag of this release.
    # When multiple binary names are specified, default archive name or $bin variable cannot be used.
    archive: app-$target
  env:
    # (required) GitHub token for uploading assets to GitHub Releases.
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Basic usage (multiple platforms)

This action supports Linux, macOS, and Windows as a host OS and supports binaries for various targets.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
          # Note that glob pattern is not supported yet.
          bin: ...
          # (optional) On which platform to distribute the `.tar.gz` file.
          # [default value: unix]
          # [possible values: all, unix, windows, none]
          tar: unix
          # (optional) On which platform to distribute the `.zip` file.
          # [default value: windows]
          # [possible values: all, unix, windows, none]
          zip: windows
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Customize archive name

By default, this action will upload an archive file with a name like $bin-$target.$extension.

You can customize archive name by archive option.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: ...
          # (optional) Archive name (non-extension portion of filename) to be uploaded.
          # [default value: $bin-$target]
          # [possible values: the following variables and any string]
          #   variables:
          #     - $bin    - Binary name (non-extension portion of filename).
          #     - $target - Target triple.
          #     - $tag    - Tag of this release.
          # When multiple binary names are specified, default archive name or $bin variable cannot be used.
          archive: $bin-$tag-$target
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Build with different features on different platforms

This action enables the systemd and io_uring features for Linux, and leave macOS, and Windows with default set of features.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        include:
          - os: ubuntu-latest
            features: systemd,io_uring
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
          # Note that glob pattern is not supported yet.
          bin: ...
          # (optional) On which platform to distribute the `.tar.gz` file.
          # [default value: unix]
          # [possible values: all, unix, windows, none]
          tar: unix
          # (optional) On which platform to distribute the `.zip` file.
          # [default value: windows]
          # [possible values: all, unix, windows, none]
          zip: windows
          # (optional) Build with the given set of features if any.
          features: ${{ matrix.features || '' }}
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Cross-compilation

By default, this action uses cross for cross-compilation (if cross supports that target). In the following example, only aarch64-unknown-linux-gnu uses cross, the rest use cargo.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    strategy:
      matrix:
        include:
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-apple-darwin
            os: macos-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
          # Note that glob pattern is not supported yet.
          bin: ...
          # (optional) Target triple, default is host triple.
          target: ${{ matrix.target }}
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

However, if the host has another cross-compilation setup, it will be respected. The following is an example using setup-cross-toolchain-action. In this example, this action uses cargo for all targets.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    strategy:
      matrix:
        include:
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-apple-darwin
            os: macos-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - name: Install cross-compilation tools
        uses: taiki-e/setup-cross-toolchain-action@v1
        with:
          target: ${{ matrix.target }}
        if: startsWith(matrix.os, 'ubuntu')
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
          # Note that glob pattern is not supported yet.
          bin: ...
          # (optional) Target triple, default is host triple.
          target: ${{ matrix.target }}
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

If the heuristic to detect host cross-compilation setups does not work well, or if you want to force the use of cargo or cross, you can use the build_tool input option.

name: Release

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional)
          changelog: CHANGELOG.md
        env:
          # (required)
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    strategy:
      matrix:
        include:
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            build_tool: cross
          - target: aarch64-apple-darwin
            os: macos-latest
            build_tool: cargo
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - name: Install cross-compilation tools
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required)
          bin: ...
          # (optional) Target triple, default is host triple.
          target: ${{ matrix.target }}
          # (optional) Tool to build binaries (cargo, or cross)
          build_tool: ${{ matrix.build_tool }}
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Include additional files

If you want include additional file to the archive, you can use the include option.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (optional) Path to changelog.
          changelog: CHANGELOG.md
        env:
          # (required) GitHub token for creating GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
          # Note that glob pattern is not supported yet.
          bin: ...
          # (optional) Comma-separated list of additional files to be included to archive.
          # Note that glob pattern is not supported yet.
          include: LICENSE,README.md
        env:
          # (required) GitHub token for uploading assets to GitHub Releases.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

By default, the expanded archive does not include the leading directory. In the above example, the directory structure of the archive would be as follows:

/<bin>
/LICENSE
/README.md

You can use the leading_dir option to create the leading directory.

- uses: taiki-e/upload-rust-binary-action@v1
  with:
    # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
    # Note that glob pattern is not supported yet.
    bin: ...
    # (optional) Comma-separated list of additional files to be included to archive.
    # Note that glob pattern is not supported yet.
    include: LICENSE,README.md
    # (optional) Whether to create the leading directory in the archive or not. default to false.
    leading_dir: true
  env:
    # (required) GitHub token for uploading assets to GitHub Releases.
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

In the above example, the directory structure of the archive would be as follows:

/<archive>/
/<archive>/<bin>
/<archive>/LICENSE
/<archive>/README.md

If you want upload additional file separately, you can use the asset option.

upload-assets:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v3
    - uses: taiki-e/upload-rust-binary-action@v1
      with:
        # (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
        # Note that glob pattern is not supported yet.
        bin: ...
        # (optional) Comma-separated list of additional files to be uploaded separately.
        # Note that glob pattern is not supported yet.
        asset: LICENSE,README.md
      env:
        # (required) GitHub token for uploading assets to GitHub Releases.
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

In the above example, the following 3 files will be uploaded:

<bin>-<target>.tar.gz
LICENSE
README.md

Other examples

Optimize Rust binary

You can optimize Rust binaries by passing the profile options. The profile options can be specified by [profile] table in Cargo.toml, cargo config, environment variables, etc.

The followings are examples of using environment variables to specify profile options:

  • lto

    env:
      CARGO_PROFILE_RELEASE_LTO: true
  • codegen-units

    env:
      CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1

Note: These options may increase the build time.

Compatibility

This action has been tested for action runners hosted by GitHub. To use this action in self-hosted runners or in containers, you will need to install at least the following:

  • rustup, cargo, rustc
  • bash, GNU Coreutils, GNU grep, GNU tar
  • gh (GitHub CLI)
  • zip (only Unix-like)
  • 7z (only Windows)

Related Projects

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].