build: github actions check added #2
Workflow file for this run
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
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 "::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/') | ||
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-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 | ||
with: | ||
env: ${{ file.path }} |