Skip to content

Add-metrics

Add-metrics #6

Workflow file for this run

name: PR Checks
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: 'go.mod'
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@0a35821d5c230e903fcfe077583637dea1b27b47 # v9.0.0
with:
version: v2.6.2
- name: Run make test
run: go test -v ./...
- name: Get PR version
id: pr_version
run: echo "version=$(grep '^VERSION :=' Makefile | cut -d' ' -f3)" >> $GITHUB_OUTPUT
- name: Get latest release version
id: latest_release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Fetch latest release tag, remove 'v' prefix if it exists.
# If no release exists, default to 0.0.0 to allow the first version to be published.
LATEST_TAG=$(gh release view --json tagName --jq .tagName 2>/dev/null || echo "v0.0.0")
echo "version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
- name: Compare versions
run: | #shell
PR_VERSION="${{ steps.pr_version.outputs.version }}"
LATEST_RELEASE_VERSION="${{ steps.latest_release.outputs.version }}"
echo "PR version: $PR_VERSION"
echo "Latest release version: $LATEST_RELEASE_VERSION"
if [ "$PR_VERSION" = "$LATEST_RELEASE_VERSION" ]; then
echo "Error: Makefile VERSION in PR is the same as the latest release."
exit 1
fi
# Using sort -V for version comparison
LATEST_VERSION=$(printf "%s\n%s" "$PR_VERSION" "$LATEST_RELEASE_VERSION" | sort -V | tail -n1)
if [ "$LATEST_VERSION" != "$PR_VERSION" ]; then
echo "Error: Makefile VERSION in PR is not greater than the latest release."
exit 1
fi
echo "Version check passed."