Skip to content

rraval/workflows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@rraval's reusable GitHub workflows

Repository for common workflows so I only have to bother getting it right once.

A comprehensive set of Rust checks intended to catch errors during development:

Usage

Add a workflow file to your repository like .github/workflows/dev.yml with the following contents:

name: Dev
on:
  push:
    branches-ignore:
      - "dependabot/**"
  pull_request:
    types: [opened, reopened]
jobs:
  all:
    uses: rraval/workflows/.github/workflows/rust_dev.yml@v1

Demo

See .github/workflows/rust_dev.example.yml for a demo that checks a toy Rust crate from this repository.

Automatically builds documentation with cargo doc and pushes the generated documentation to a separate branch. By default, uses the gh-pages branch which allows seamless integration with GitHub Pages.

Each build force pushes a new commit containing only documentation artifacts as the sole commit to the branch, allowing git garbage collection to auomatically free up data from previous builds.

Usage

Add a workflow file to your repository like .github/workflows/doc.yml with the following contents:

name: Doc
on:
  push:
    branches:
      - main
jobs:
  all:
    uses: rraval/workflows/.github/workflows/rust_doc.yml@v1

Then, enable GitHub Pages on the GitHub repository:

  • Navigate to Settings
  • Click on Pages in the left sidebar
  • In the Build and deployment section
  • Souce: Deploy from a branch
  • Branch: gh-pages with / (root)

Demo

See .github/workflows/rust_doc.example.yml for a demo that generates documentation for a toy Rust project in this repo (with many internal crates).

The generates documentation is viewable at https://rraval.github.io/workflows/main/

Publishes the crate to crates.io with cargo publish.

Usage

Navigate to https://crates.io/settings/tokens and generate a new token specific to your repository.

Follow the GitHub instructions for creating a repository secret and create a secret named CRATES_IO_TOKEN with the value from https://crates.io/settings/tokens.

Add a workflow file to your repository like .github/workflows/publish.yml with the following contents:

name: Publish
on:
  release:
    types: [published]
jobs:
  all:
    uses: rraval/workflows/.github/workflows/rust_publish.yml@v1
    secrets:
      CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

Demo

See .github/workflows/rust_publish.example.yml for a demo that publishes a toy Rust crate from this repository.

Builds Rust binaries (Linux and Mac OS X) and uploads them as artifacts to a GitHub release.

Usage

Add a workflow file to your repository like .github/workflows/release.yml with the following contents, replacing <NAME-OF-YOUR-CRATE-BINARY> with the binary to build as specified in the Cargo.toml (if you're not doing anything fancy, this is usually the same as the Cargo package name).

name: Release
on:
  release:
    types: [published]
jobs:
  main:
    uses: rraval/workflows/.github/workflows/rust_release_binary.yml@v1
    with:
      CARGO_BINARY_NAME: <NAME-OF-YOUR-CRATE-BINARY>

Demo

See .github/workflows/rust_release_binary.example.yml for a demo that builds and uploads 2 binaries for a toy Rust crate from this repository.

Enables auto-merge for PRs if they satisfy all other checks. Useful for evergreen repositories that want to automate dependabot PRs.

Usage

Add a workflow file to your repository like .github/workflows/auto-merge.yml with the following contents:

name: Auto-merge dependabot PRs
on: pull_request_target
jobs:
  all:
    uses: rraval/workflows/.github/workflows/auto-merge-pr.yml@v1
    if: github.actor == 'dependabot[bot]'

Warning

Verify the if condition on the job. Mistakes can allow anybody to merge PRs and compromise the repo.

Demo

See .github/workflows/auto-merge-pr.example.yml for a demo only allows merges into the automerge-demo-base branch.