Skip to content

Merge pull request #443 from siketyan/dependabot/cargo/octocrab-0.41.2 #938

Merge pull request #443 from siketyan/dependabot/cargo/octocrab-0.41.2

Merge pull request #443 from siketyan/dependabot/cargo/octocrab-0.41.2 #938

Workflow file for this run

name: Rust
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
env:
CARGO_TERM_COLOR: always
jobs:
checks:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rustfmt,clippy
- name: Run rustfmt
run: cargo fmt --all --check
- name: Run clippy
uses: giraffate/clippy-action@v1
with:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: cargo test --all-features
build:
strategy:
matrix:
target:
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
include:
- cargo: cargo
artifact: ghr
- target: x86_64-pc-windows-msvc
host: windows-2022
artifact: ghr.exe
- target: x86_64-apple-darwin
host: macos-12
- target: aarch64-apple-darwin
host: macos-12
- target: x86_64-unknown-linux-gnu
host: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
host: ubuntu-22.04
cargo: cross
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: ${{ matrix.cargo == 'cross' }}
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo-binstall -y cross
- id: cache-key
run: echo "key=$(echo '${{ toJSON(matrix) }}' | shasum -a 256)" >> $GITHUB_OUTPUT
- uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.cache-key.outputs.key }}
- name: Build
run: ${{ matrix.cargo }} build --release --features vendored --target '${{ matrix.target }}'
- name: Compress artifacts into .tar.gz file
run: tar -C ./target/${{ matrix.target }}/release -czf ghr-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
- uses: actions/upload-artifact@v4
with:
name: ghr-${{ matrix.target }}
path: ghr-${{ matrix.target }}.tar.gz
- uses: svenstaro/upload-release-action@v2
if: ${{ github.event_name == 'release' }}
with:
file: ghr-${{ matrix.target }}.tar.gz
overwrite: true
deploy:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'release' }}
needs:
- checks
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
- name: Log into crates.io
run: cargo login '${{ secrets.CRATES_IO_TOKEN }}'
- name: Publish to crates.io
run: cargo publish --allow-dirty
brew:
runs-on: macos-13
if: ${{ github.event_name == 'release' }}
needs:
- build
steps:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Set up git
uses: Homebrew/actions/git-user-config@master
- name: Tap s6n-jp/tap
run: brew tap s6n-jp/tap
- name: Create a bump PR
uses: Homebrew/actions/bump-packages@master
with:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
formulae: s6n-jp/tap/ghr
scoop:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'release' }}
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Release to Scoop Bucket
uses: siketyan/release-to-registry-action@7e2a91ef78e61dccdb2e8b9401ae54ec58fab4fc
with:
path: 'ghr.json'
assets: |-
windows_x86_64=ghr-x86_64-pc-windows-msvc.tar.gz
message: 'feat(ghr): Release ${{ github.event.release.tag_name }}'
template: './resources/scoop/ghr.json.mustache'
token: '${{ secrets.SCOOP_BUCKET_TOKEN }}'
hash: 'sha256'
targetRepo: 'scoop-bucket'
branch: 'ghr/${{ github.event.release.tag_name }}'
author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
committer: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'