Skip to content

build: github actions check added #1

build: github actions check added

build: github actions check added #1

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@v2
- 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 "::set-output name=tag::$(git describe --tags --abbrev=0)"
- name: Check Version
id: check_version
run: |
latest_tag=${{ steps.get_tag.outputs.tag }}
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/')
if [[ "$provided_version" == "$latest_version" ]]; then
echo "Provided version is equal to the latest tag."
echo "::set-output name=trigger_next_action::false"
exit 1
elif [[ "$provided_version" < "$latest_version" ]]; then
echo "Provided version is lower than the latest tag."
echo "::set-output name=trigger_next_action::false"
exit 1
else
echo "Provided version is higher than the latest tag."
echo "::set-output name=trigger_next_action::true"
fi