Skip to content

build: github actions check added #4

build: github actions check added

build: github actions check added #4

Workflow file for this run

name: Check Version
on:
pull_request:
branches:
- main
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get version
id: yq
uses: mikefarah/yq@master
with:
cmd: yq -r '.version' 'pubspec.yaml'
- name: Print version
run: echo ${{ steps.yq.outputs.result }}
- name: Get Latest Tag
id: get_tag
run: echo "$(git describe --tags --abbrev=0)"
- name: Check Version
id: check_version
env:
TRIGGER_NEXT_ACTION: false
run: |
latest_tag=${{ steps.get_tag.outputs.result }}
provided_version=${{ steps.yq.outputs.result }}
# Extract numerical version parts from the tags
latest_version=$(echo "$latest_tag" | sed 's/v\?\([0-9.]*\)[-a-zA-Z]*$/\1/')
provided_version=$(echo "$provided_version" | sed 's/v\?\([0-9.]*\)[-a-zA-Z]*$/\1/')
echo "Latest version: $latest_version"
echo "Provided version: $provided_version"
if [[ "$provided_version" == "$latest_version" ]]; then
echo "Provided version is equal to the latest tag."
echo "set-env:TRIGGER_NEXT_ACTION=false" >> $GITHUB_ENV
exit 1
elif [[ "$provided_version" < "$latest_version" ]]; then
echo "Provided version is lower than the latest tag."
echo "set-env:TRIGGER_NEXT_ACTION=false" >> $GITHUB_ENV
exit 1
else
echo "Provided version is higher than the latest tag."
echo "set-env:TRIGGER_NEXT_ACTION=true" >> $GITHUB_ENV
fi