-
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
107 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,71 @@ | ||
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 base | ||
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 push | ||
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 or base | ||
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 which version is greater | ||
run: echo "GREATER_VER=$(./vergt.sh $VERSION $BEFORE_VERSION)" >> $GITHUB_ENV | ||
|
||
- name: Fail if current version is not greater | ||
run: exit 1 | ||
if: ${{ env.GREATER_VER != 1 }} |
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,34 @@ | ||
#!/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 1 | ||
exit | ||
fi | ||
if ((10#${ver1[i]} < 10#${ver2[i]})) | ||
then | ||
# if ver2 greater than ver1 in most major differing field | ||
echo 2 | ||
exit | ||
fi | ||
done | ||
echo 0 | ||
exit |