Skip to content

Add CI job to publish on crates.io when a release is tagged #1150

Add CI job to publish on crates.io when a release is tagged

Add CI job to publish on crates.io when a release is tagged #1150

Workflow file for this run

name: Continuous Integration
on:
push:
branches:
- master
tags:
- 'release-[0-9]+-[0-9]+-[0-9]+'
pull_request:
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
default: true
- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy-check:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get date for registry cache
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cargo registry cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
restore-keys: ${{ runner.os }}-cargo-registry-
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: clippy
default: true
- name: Get cargo-cache latest version
id: cargocacheversion
run: echo "::set-output name=version::$(cargo search 'cargo-cache' --limit 1 | head -n 1 | cut -d ' ' -f 3 | cut -d '"' -f 2)"
- name: Cargo binaries cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/cargo-cache
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-cargo-binaries-${{ steps.cargocacheversion.outputs.version }}
- name: Install cargo-cache
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-cache --version ${{ steps.cargocacheversion.outputs.version }}
- name: Clean cargo cache of old items
uses: actions-rs/cargo@v1
with:
command: cache
args: clean-unref
- name: Get rustc version for caching
id: rustcversion
run: echo "::set-output name=version::$(rustc --version | cut -d ' ' -f 2)"
- name: Build cache
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-clippy-${{ steps.rustcversion.outputs.version }}-${{ hashFiles('**/Cargo.toml') }}
- name: System dependencies
run: sudo apt-get install libwayland-dev
- name: Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --all-features --all-targets -- -D warnings
cargo-deny:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- uses: EmbarkStudios/cargo-deny-action@v1
check-minimal:
needs:
- format
- clippy-check
env:
RUSTFLAGS: "-D warnings"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get date for registry cache
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cargo registry cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
default: true
- name: System dependencies
run: sudo apt-get install libwayland-dev
- name: Downgrade to minimal dependencies
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all --all-features
msrv:
needs:
- format
- clippy-check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get date for registry cache
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cargo registry cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.65.0
override: true
profile: minimal
default: true
- name: Get rustc version for caching
id: rustcversion
run: echo "::set-output name=version::$(rustc --version | cut -d ' ' -f 2)"
- name: Build cache
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-test-${{ steps.rustcversion.outputs.version }}-${{ hashFiles('**/Cargo.toml') }}
- name: System dependencies
run: sudo apt-get install libwayland-dev
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all --all-features
coverage-main:
needs:
- format
- clippy-check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get date for registry cache
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cargo registry cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
- name: System dependencies
run: sudo apt-get install libwayland-dev
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
default: true
components: llvm-tools-preview, rustfmt
- name: Runtime directory
run: |
mkdir -p $(pwd)/.runtime
echo "XDG_RUNTIME_DIR=$(pwd)/.runtime" >> $GITHUB_ENV
- name: Get grcov latest version
id: grcovversion
run: echo "::set-output name=version::$(cargo search 'grcov' --limit 1 | head -n 1 | cut -d ' ' -f 3 | cut -d '"' -f 2)"
- name: grcov cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/grcov
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-grcov-${{ steps.grcovversion.outputs.version }}
- name: Install grcov
uses: actions-rs/cargo@v1
with:
command: install
args: grcov --version ${{ steps.grcovversion.outputs.version }}
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --exclude 'wayland-tests'
env:
LLVM_PROFILE_FILE: "wayland-rs-%p-%m.profraw"
RUSTFLAGS: "-Cinstrument-coverage --cfg coverage"
- name: Coverage
run: grcov . --binary-path ./target/debug -s . -t lcov --branch --llvm --ignore-not-existing --ignore 'wayland-backend/src/test/*' --ignore '*/examples/*' --ignore '*/tests/*' --ignore '*/.cargo/registry/*' --excl-br-start "mod tests \{" --excl-start "mod tests \{" --excl-br-line "#\[derive\(" --excl-line "#\[derive\(" -o lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
flags: main
coverage-tests:
needs:
- format
- clippy-check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
client_feature: ["", "client_system"]
server_feature: ["", "server_system"]
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get date for registry cache
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cargo registry cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
- name: System dependencies
run: sudo apt-get install libwayland-dev
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
default: true
components: llvm-tools-preview, rustfmt
- name: Runtime directory
run: |
mkdir -p $(pwd)/.runtime
echo "XDG_RUNTIME_DIR=$(pwd)/.runtime" >> $GITHUB_ENV
- name: Get grcov latest version
id: grcovversion
run: echo "::set-output name=version::$(cargo search 'grcov' --limit 1 | head -n 1 | cut -d ' ' -f 3 | cut -d '"' -f 2)"
- name: grcov cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/grcov
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-grcov-${{ steps.grcovversion.outputs.version }}
- name: Install grcov
uses: actions-rs/cargo@v1
with:
command: install
args: grcov --version ${{ steps.grcovversion.outputs.version }}
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: -p wayland-tests --features "${{ matrix.client_feature }} ${{ matrix.server_feature}}"
env:
LLVM_PROFILE_FILE: "wayland-rs-%p-%m.profraw"
RUSTFLAGS: "-Cinstrument-coverage --cfg coverage"
- name: Coverage
run: grcov . --binary-path ./target/debug -s . -t lcov --branch --llvm --ignore-not-existing --ignore 'wayland-tests/*' --ignore '*/examples/*' --ignore '*/tests/*' --ignore '*/.cargo/registry/*' --excl-br-start "mod tests \{" --excl-start "mod tests \{" --excl-br-line "#\[derive\(" --excl-line "#\[derive\(" -o lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
flags: test-${{ matrix.client_feature }}-${{ matrix.server_feature }}
doc:
name: Documentation on Github Pages
runs-on: ubuntu-latest
needs:
- format
- clippy-check
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get date for registry cache
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cargo registry cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }}
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: System dependencies
run: sudo apt-get install libwayland-client0 libwayland-server0
- name: Build Documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --all --no-deps --all-features
- name: Setup index
run: cp ./doc/index.html ./doc/rust.css ./target/doc/
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
force_orphan: true
publish:
needs:
- format
- doc
- check-minimal
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish crates
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CRATES_TOKEN }}
args: --no-verify
dry-run: ${{ !(github.repository == 'Smithay/wayland-rs' && startsWith(github.ref, 'refs/tags/release-')) }}
ignore-unpublished-changes: ${{ !(github.repository == 'Smithay/wayland-rs' && startsWith(github.ref, 'refs/tags/release-')) }}