Skip to content

Improve version determination in publish workflow#5

Merged
lupodevelop merged 1 commit intomainfrom
workflow/ci-test
Nov 16, 2025
Merged

Improve version determination in publish workflow#5
lupodevelop merged 1 commit intomainfrom
workflow/ci-test

Conversation

@lupodevelop
Copy link
Owner

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.

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.
Copilot AI review requested due to automatic review settings November 16, 2025 10:40
@lupodevelop lupodevelop merged commit 31dcb97 into main Nov 16, 2025
5 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the robustness of the publish workflow by adding conditional version determination logic. The workflow now checks if it's triggered by a tag push and extracts the version from the tag, or falls back to reading the version from gleam.toml when triggered by a merged PR.

Key Changes

  • Added conditional logic to check if the workflow is triggered by a tag push
  • Implemented fallback to read version from gleam.toml when no tag is present
  • Updated step name from "Determine version from tag" to "Determine version" to reflect the broader functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

VERSION=${TAG#v}
echo "Determined version ${VERSION} from tag ${TAG}"
else
VERSION=$(grep '^version' gleam.toml | sed -E 's/.*= *"([^\"]+)".*/\1/') || true
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The escaped double quote in the character class [^\"]+ is unnecessary and incorrect. Since the sed expression is enclosed in single quotes, the backslash before the double quote is treated literally. This should be [^"]+ instead. While this may work in practice, it's technically incorrect regex syntax.

Copilot uses AI. Check for mistakes.
VERSION=${TAG#v}
echo "Determined version ${VERSION} from tag ${TAG}"
else
VERSION=$(grep '^version' gleam.toml | sed -E 's/.*= *"([^\"]+)".*/\1/') || true
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The || true at the end of this line suppresses errors and could result in an empty VERSION variable if grep or sed fails. This undermines the set -euo pipefail on line 78. Consider removing || true to allow the step to fail properly if the version cannot be determined, or add explicit validation after this line to check if VERSION is non-empty and fail with a clear error message if it's not.

Suggested change
VERSION=$(grep '^version' gleam.toml | sed -E 's/.*= *"([^\"]+)".*/\1/') || true
VERSION=$(grep '^version' gleam.toml | sed -E 's/.*= *"([^\"]+)".*/\1/')
if [ -z "${VERSION}" ]; then
echo "Error: Could not determine version from gleam.toml" >&2
exit 1
fi

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants