Bumping package version #42
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
# https://bl.ocks.org/PurpleBooth/84b3d7d6669f77d5a53801a258ed269a | |
name: lint, test and publish | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry | |
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git | |
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- name: Run check | |
run: cargo check | |
test: | |
runs-on: '${{ matrix.os }}' | |
strategy: | |
matrix: | |
include: | |
# TODO: fix it | |
# - os: macos-latest | |
- os: ubuntu-latest | |
- os: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry | |
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git | |
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- name: Run Test | |
run: cargo test --verbose | |
- name: Run Cargo Run | |
run: cargo run -- -h | |
lints: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry | |
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git | |
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
override: true | |
components: 'rustfmt, clippy' | |
- name: Run cargo fmt | |
run: cargo fmt --all -- --check | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: '-- -D warnings' | |
version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
with: | |
lfs: true | |
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- id: get_previous_version | |
run: echo ::set-output name=PREVIOUS_VERSION::$(git describe --tags "$(git rev-list --tags --max-count=1)") | |
shell: bash | |
- id: semvers | |
uses: WyriHaximus/github-action-next-semvers@master | |
with: | |
version: '${{ steps.get_previous_version.outputs.PREVIOUS_VERSION }}' | |
- run: mkdir -p ./version | |
- if: "!contains(github.event.head_commit.message, 'BC BREAK') && !contains(github.event.head_commit.message, 'Signed-off-by: dependabot-preview[bot] <[email protected]>')" | |
run: echo "$VERSION" >./version/version | |
env: | |
VERSION: ${{ steps.semvers.outputs.v_minor }} | |
- if: "contains(github.event.head_commit.message, 'Signed-off-by: dependabot-preview[bot] <[email protected]>')" | |
run: echo "$VERSION" >./version/version | |
env: | |
VERSION: ${{ steps.semvers.outputs.v_patch }} | |
- run: echo "$VERSION" > ./version/version | |
env: | |
VERSION: ${{ steps.semvers.outputs.v_major }} | |
if: "contains(github.event.head_commit.message, 'BC BREAK')" | |
- uses: actions/upload-artifact@master | |
with: | |
name: version | |
path: ./version/version | |
build: | |
needs: | |
- version | |
- lints | |
- test | |
- check | |
runs-on: '${{ matrix.os }}' | |
strategy: | |
matrix: | |
include: | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
suffix: '' | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
suffix: '' | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
suffix: .exe | |
steps: | |
- uses: actions/checkout@master | |
with: | |
lfs: true | |
- id: get_repository_name | |
run: echo ::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") | |
shell: bash | |
- uses: actions/download-artifact@master | |
with: | |
name: version | |
- id: get_version | |
run: 'echo ::set-output "name=VERSION::$(cat ./version/version)"' | |
shell: bash | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry | |
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git | |
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}' | |
- uses: actions/cache@v1 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install cargo cargo-bump | |
run: cargo install cargo-bump | |
- shell: bash | |
env: | |
VERSION: '${{ steps.get_version.outputs.VERSION }}' | |
run: cargo bump patch | |
- name: Cargo Build | |
env: | |
VERSION: '${{ steps.get_version.outputs.VERSION }}' | |
REPOSITORY_NAME: '${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}' | |
run: cargo build --release | |
# - uses: actions/upload-artifact@master | |
# with: | |
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-${{ matrix.target }} | |
# path: ./target/release/${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}${{ matrix.suffix }} | |
# release: | |
# if: github.ref == 'refs/heads/main' | |
# needs: | |
# - build | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@master | |
# with: | |
# lfs: true | |
# - id: get_repository_name | |
# run: echo ::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") | |
# shell: bash | |
# - uses: actions/download-artifact@master | |
# with: | |
# name: version | |
# - id: get_version | |
# run: 'echo ::set-output name=VERSION::$(cat ./version/version)' | |
# shell: bash | |
# - uses: actions/download-artifact@master | |
# with: | |
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu | |
# - uses: actions/download-artifact@master | |
# with: | |
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-apple-darwin | |
# - uses: actions/download-artifact@master | |
# with: | |
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-pc-windows-msvc | |
# - name: Install cargo cargo-bump | |
# run: cargo install cargo-bump | |
# - shell: bash | |
# env: | |
# VERSION: '${{ steps.get_version.outputs.VERSION }}' | |
# run: cargo bump patch | |
# - uses: stefanzweifel/[email protected] | |
# with: | |
# commit_message: Bump cargo version | |
# branch: ${{ github.head_ref }} | |
# file_pattern: Cargo.toml | |
# push_options: '--force' | |
# - id: create_release | |
# uses: actions/[email protected] | |
# env: | |
# GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
# with: | |
# tag_name: '${{ steps.get_version.outputs.VERSION }}' | |
# release_name: 'Release ${{ steps.get_version.outputs.VERSION }}' | |
# draft: false | |
# prerelease: false | |
# - id: publish_cargo | |
# uses: katyo/publish-crates@v1 | |
# with: | |
# registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} |