-
Notifications
You must be signed in to change notification settings - Fork 0
Improve version determination in publish workflow #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||
|
||||||||||||||
| 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 |
There was a problem hiding this comment.
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.