Handle crate names containing hyphens #109
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
# Template Reference: https://www.infinyon.com/blog/2021/04/github-actions-best-practices/ | |
on: | |
push: | |
branches: [ master, codeforce, dev ] | |
pull_request: | |
branches: [ master, codeforce ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Cargo test (${{ matrix.rust }}) (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
rust: [stable, 1.56, 1.61] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust ${{ matrix.rust }} | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
profile: minimal | |
override: true | |
- name: Cache cargo registry | |
uses: actions/cache@v2 | |
continue-on-error: false | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-build | |
restore-keys: | | |
${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}- | |
${{ runner.os }}-cargo-${{ matrix.rust }}- | |
${{ runner.os }}-cargo- | |
# Real tests starts here | |
- name: Check version | |
run: rustup --version && rustc --version && cargo --version | |
- name: Install rustfmt | |
run: | | |
rustup component add rustfmt | |
which rustfmt && rustfmt --version | |
- name: Build | |
run: cargo build --verbose | |
- name: Run tests | |
run: cargo test --verbose | |
- name: Install | |
run: cargo install --path . | |
- name: Package | |
run: cargo package --verbose | |
- name: clippy | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
rustup component add clippy | |
cargo clippy | |
coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cache cargo registry | |
uses: actions/cache@v2 | |
continue-on-error: false | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-coverage | |
restore-keys: | | |
${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}- | |
${{ runner.os }}-cargo-${{ matrix.rust }}- | |
${{ runner.os }}-cargo- | |
- uses: actions/checkout@v2 | |
- name: Build And Coverage | |
run: ./coverage.sh | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: coverage | |
path: ./coverage/ | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Cache cargo registry | |
uses: actions/cache@v2 | |
continue-on-error: false | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.toml') }}-release | |
restore-keys: | | |
${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.toml') }}- | |
${{ runner.os }}-cargo-stable- | |
${{ runner.os }}-cargo- | |
# End of rust template | |
# - name: Install toolkit | |
# run: cargo install cargo-bump | |
- name: Bump version | |
run: | | |
git config --global user.name 'Endle' | |
git config --global user.email '[email protected]' | |
git branch --show-current | |
python3 --version | |
python3 bump_version.py | |
- name: Push to Github and crates | |
env: | |
CRATES_SECRET: ${{ secrets.CRATES_ENDLE }} | |
run: | | |
if [[ -f "created_new_commit.success" ]]; then | |
cat created_new_commit.success | |
rm created_new_commit.success | |
echo "Following https://stackoverflow.com/a/58393457/1166518" | |
git push origin master | |
cargo login "$CRATES_SECRET" | |
cargo publish -v | |
fi | |