Skip to content

fix: azapi 1.13 compatibility #188

fix: azapi 1.13 compatibility

fix: azapi 1.13 compatibility #188

---
name: module version
on:
pull_request:
branches:
- main
paths:
- '**.tf'
- '**.tf.json'
workflow_dispatch:
permissions:
contents: read
jobs:
checkversion:
env:
SEMVER_REGEX: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
MODULE_VERSION_FILE: locals.version.tf.json
MODULE_JSON_QUERY: .locals.module_version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
VER=$(curl --silent -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .name | sed s/^v//)
if echo "$VER" | grep -P -qv "$SEMVER_REGEX"; then
echo "Release version $VER is not a valid semantic version"
exit 1
fi
echo LATEST_RELEASE="$VER" >> "$GITHUB_ENV"
name: Get latest release version
- run: |
VER=$(jq -r '${{ env.MODULE_JSON_QUERY }}' < ${{ env.MODULE_VERSION_FILE }})
if echo "$VER" | grep -P -qv "$SEMVER_REGEX"; then
echo "Module version $VER is not a valid semantic version"
exit 1
fi
echo MODULE_VERSION="$VER" >> "$GITHUB_ENV"
name: Get module version
- run: |
MODVERMAJOR=$(echo ${{ env.MODULE_VERSION }} | cut -d. -f1)
MODVERMINOR=$(echo ${{ env.MODULE_VERSION }} | cut -d. -f2)
MODVERPATCH=$(echo ${{ env.MODULE_VERSION }} | cut -d. -f3)
RELVERMAJOR=$(echo ${{ env.LATEST_RELEASE }} | cut -d. -f1)
RELVERMINOR=$(echo ${{ env.LATEST_RELEASE }} | cut -d. -f2)
RELVERPATCH=$(echo ${{ env.LATEST_RELEASE }} | cut -d. -f3)
if [ "$MODVERMAJOR" -lt "$RELVERMAJOR" ]; then
echo "Module version ${{ env.MODULE_VERSION }} is less than latest release ${{ env.LATEST_RELEASE }}"
exit 1
fi
if [ "$MODVERMAJOR" -eq "$RELVERMAJOR" ] && [ "$MODVERMINOR" -lt "$RELVERMINOR" ]; then
echo "Module version ${{ env.MODULE_VERSION }} is less than latest release ${{ env.LATEST_RELEASE }}"
exit 1
fi
if [ "$MODVERMAJOR" -eq "$RELVERMAJOR" ] && [ "$MODVERMINOR" -eq "$RELVERMINOR" ] && [ "$MODVERPATCH" -lt "$RELVERPATCH" ]; then
echo "Module version ${{ env.MODULE_VERSION }} is less than latest release ${{ env.LATEST_RELEASE }}"
exit 1
fi
name: Check module version is greater than latest release