Skip to content

build: github actions check added #7

build: github actions check added

build: github actions check added #7

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: |
PAT=${{ secrets.GITHUB_TOKEN }}
REPO_OWNER=${{ github.repository_owner }}
REPO_NAME=${{ github.repository }}
LATEST_TAG=$(curl -s -H "Authorization: token $PAT" "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest" | jq -r ".tag_name")
printf "::set-output name=latest::%s" "${LATEST_TAG}"
- name: Print version
run: echo "provided_version=${{ steps.yq.outputs.result }} and latest_tag=${{ steps.get_tag.outputs.latest }}"
- name: Check Version
id: check_version
run: |
latest_tag=${{ steps.get_tag.outputs.latest }}
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
printf "::set-output name=trigger_next_action::%s" "false"
exit 1
elif [[ "$provided_version" < "$latest_version" ]]; then
printf "::set-output name=trigger_next_action::%s" "false"
exit 1
else
printf "::set-output name=trigger_next_action::%s" "true"
echo "true"
fi
- name: Trigger Next Action
run: echo "Trigger Next Action ${{ steps.check_version.outputs.trigger_next_action }}
env:
TRIGGER_NEXT_ACTION: ${{ steps.check_version.outputs.trigger_next_action }}