Skip to content

Commit

Permalink
Merge branch 'main' into ah
Browse files Browse the repository at this point in the history
  • Loading branch information
Slesarew authored Mar 7, 2024
2 parents ebbd93e + faa543f commit 7b077e3
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 17 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/rust-cargo-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Rust cargo build and draft release

on:
push:
branches:
- main

jobs:
cargo-build:
name: Cargo build
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:

- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout sources
uses: actions/[email protected]
with:
fetch-depth: 50
submodules: 'recursive'

- name: Install Rust stable toolchain
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: stable
override: true

- name: Rust Cache
uses: Swatinem/[email protected]

- name: cargo build
run: cargo build --release

- name: Get package version
run: >
echo "VERSION=$(
cargo metadata --format-version=1 --no-deps |
jq -r '.packages[] | select(.name == "kalatori") | .version'
)" >> $GITHUB_ENV
- name: Draft release binary
run: gh release create -d $VERSION ./target/release/kalatori --generate-notes
71 changes: 71 additions & 0 deletions .github/workflows/rust-check-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Rust check version

on:
pull_request:
types:
- opened
- edited
- synchronize
branches:
- main

jobs:
version:
name: Check version
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:

- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install Rust stable toolchain
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: stable
override: true

- name: Checkout base
uses: actions/[email protected]
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 50
submodules: 'recursive'

- name: Checkout before push
uses: actions/[email protected]
if: github.event_name != 'pull_request'
with:
ref: ${{ github.event.before }}
fetch-depth: 50
submodules: 'recursive'

- name: Get package version before or base
run: >
echo "BEFORE_VERSION=$(
cargo metadata --format-version=1 --no-deps |
jq -r '.packages[] | select(.name == "kalatori") | .version'
)" >> $GITHUB_ENV
- name: Checkout sources
uses: actions/[email protected]
with:
fetch-depth: 50
submodules: 'recursive'

- name: Get package version
run: >
echo "VERSION=$(
cargo metadata --format-version=1 --no-deps |
jq -r '.packages[] | select(.name == "kalatori") | .version'
)" >> $GITHUB_ENV
- name: Check which version is greater
run: ./is_version_greater.sh $VERSION $BEFORE_VERSION


91 changes: 75 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ members = ["kalatori-ah"]
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["full"] }
anyhow = "1"
env_logger = "0.10"
env_logger = "0.11"
log = "0.4"
subxt = { version = "0.34", features = ["substrate-compat"] }
axum = "0.7"
Expand Down
31 changes: 31 additions & 0 deletions is_version_greater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
IFS=.
version=($1)
before_version=($2)
# starting from minor of version if version shorter before_version
# fill absent fields in version with zeros
for ((i=${#version[@]}; i<${#before_version[@]}; i++))
do
version[i]=0
done
# starting from major of version
for ((i=0; i<${#version[@]}; i++))
do
if [[ -z ${before_version[i]} ]]
then
# if before_version shorter version then
# fill absent fields in before_version with zeros
ver2[i]=0
fi
if ((10#${version[i]} > 10#${before_version[i]}))
then
# if version greater than before_version in most major differing field
exit 0
fi
if ((10#${version[i]} < 10#${before_version[i]}))
then
# if version is not greater in most major differing field
exit 1
fi
done
exit 1

0 comments on commit 7b077e3

Please sign in to comment.