Skip to content

Merge pull request #209 from siketyan/dependabot/cargo/serde-1.0.183 #456

Merge pull request #209 from siketyan/dependabot/cargo/serde-1.0.183

Merge pull request #209 from siketyan/dependabot/cargo/serde-1.0.183 #456

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@v3
- 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@v3
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@v3
with:
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@v3
- uses: Swatinem/rust-cache@v2
- name: Install latest stable
uses: ructions/toolchain@v2
with:
toolchain: stable
override: true
- name: Log into crates.io
uses: ructions/cargo@v1
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
uses: ructions/cargo@v1
with:
command: publish
args: --allow-dirty
brew:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'release' }}
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Release to Homebrew Tap
uses: siketyan/release-to-registry-action@7e2a91ef78e61dccdb2e8b9401ae54ec58fab4fc
with:
path: 'Formula/ghr.rb'
assets: |-
macos_x86_64=ghr-x86_64-apple-darwin.tar.gz
macos_aarch64=ghr-aarch64-apple-darwin.tar.gz
linux_x86_64=ghr-x86_64-unknown-linux-gnu.tar.gz
linux_aarch64=ghr-aarch64-unknown-linux-gnu.tar.gz
message: 'feat(ghr): Release ${{ github.event.release.tag_name }}'
template: './resources/formula/ghr.rb.mustache'
token: '${{ secrets.HOMEBREW_TAP_TOKEN }}'
hash: 'sha256'
targetRepo: 'homebrew-tap'
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>'
- 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>'