Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/publish-gleam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
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.
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)
Expand Down