From 1c1d2d83ea46ee3de07cadd6b250b92226b9538a Mon Sep 17 00:00:00 2001 From: Daniele Date: Sun, 16 Nov 2025 11:39:36 +0100 Subject: [PATCH] Improve version determination in publish workflow Update the GitHub Actions workflow to determine the version from the tag if available, or fall back to the version in gleam.toml when triggered by a merged PR. This makes the workflow more robust for different trigger scenarios. --- .github/workflows/publish-gleam.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-gleam.yml b/.github/workflows/publish-gleam.yml index e3524c3..2ef7ec1 100644 --- a/.github/workflows/publish-gleam.yml +++ b/.github/workflows/publish-gleam.yml @@ -72,12 +72,20 @@ jobs: set -eux gleam test - - name: Determine version from tag + - name: Determine version id: ver run: | - TAG=${GITHUB_REF#refs/tags/} - VERSION=${TAG#v} - echo "Determined version ${VERSION} from tag ${TAG}" + set -euo pipefail + # If this run was triggered by a tag push, derive version from the tag. + # If triggered by a merged PR (no tag yet), fall back to the version in gleam.toml. + if echo "${GITHUB_REF}" | grep -q '^refs/tags/'; then + TAG=${GITHUB_REF#refs/tags/} + VERSION=${TAG#v} + echo "Determined version ${VERSION} from tag ${TAG}" + else + VERSION=$(grep '^version' gleam.toml | sed -E 's/.*= *"([^\"]+)".*/\1/') || true + echo "GITHUB_REF=${GITHUB_REF}; using version from gleam.toml: ${VERSION}" + fi echo "version=${VERSION}" >> $GITHUB_OUTPUT - name: Create tag from gleam.toml (on merged PR)