-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Added build and draft release job
Added package version bump check
- Loading branch information
Showing
3 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Rust check version | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- stable | ||
|
||
jobs: | ||
version: | ||
name: Check version | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
|
||
- name: Cancel Previous Runs | ||
uses: styfle/cancel-workflow-action@0.12.1 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Install Rust stable toolchain | ||
uses: actions-rs/toolchain@v1.0.7 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Checkout before | ||
uses: actions/checkout@v4.1.1 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
ref: ${{ github.event.pull_request.base.ref }} | ||
fetch-depth: 50 | ||
submodules: 'recursive' | ||
|
||
- name: Checkout before | ||
uses: actions/checkout@v4.1.1 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
ref: ${{ github.event.before }} | ||
fetch-depth: 50 | ||
submodules: 'recursive' | ||
|
||
- name: Get package version before | ||
run: > | ||
echo "BEFORE_VERSION=$( | ||
cargo metadata --no-deps | | ||
jq -r '.packages[] | select(.name == "kalatori") | .version' | ||
)" >> $GITHUB_ENV | ||
- name: Checkout sources | ||
uses: actions/checkout@v4.1.1 | ||
with: | ||
fetch-depth: 50 | ||
submodules: 'recursive' | ||
|
||
- name: Get package version | ||
run: > | ||
echo "VERSION=$( | ||
cargo metadata --no-deps | | ||
jq -r '.packages[] | select(.name == "kalatori") | .version' | ||
)" >> $GITHUB_ENV | ||
- name: Check version and fail | ||
run: exit 1 | ||
if: ${{ ./ver1gt.sh env.VERSION env.BEFORE_VERSION }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
IFS=. | ||
ver1=($1) | ||
ver2=($2) | ||
# starting from minor of ver1 if ver1 shorter ver2 | ||
# fill absent fields in ver1 with zeros | ||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) | ||
do | ||
ver1[i]=0 | ||
done | ||
# starting from major of ver1 | ||
for ((i=0; i<${#ver1[@]}; i++)) | ||
do | ||
if [[ -z ${ver2[i]} ]] | ||
then | ||
# if ver2 shorter ver1 then | ||
# fill absent fields in ver2 with zeros | ||
ver2[i]=0 | ||
fi | ||
if ((10#${ver1[i]} > 10#${ver2[i]})) | ||
then | ||
# if ver1 greater than ver2 in most major differing field | ||
echo true | ||
exit | ||
fi | ||
if ((10#${ver1[i]} < 10#${ver2[i]})) | ||
then | ||
# if ver1 less than ver 2 in most major differing field | ||
echo false | ||
exit | ||
fi | ||
done | ||
exit |