Skip to content

feat: Add craft releases#44

Open
bitsandfoxes wants to merge 3 commits intomainfrom
feat/releasing
Open

feat: Add craft releases#44
bitsandfoxes wants to merge 3 commits intomainfrom
feat/releasing

Conversation

@bitsandfoxes
Copy link
Contributor

#skip-changelog

Comment on lines +4 to +9
preReleaseCommand: >-
pwsh -Command "
@('app-runner/SentryAppRunner.psd1', 'sentry-api-client/SentryApiClient.psd1') | ForEach-Object {
(Get-Content $_) -replace \"ModuleVersion = '.*'\", \"ModuleVersion = '$env:CRAFT_NEW_VERSION'\" | Set-Content $_
}
"
Copy link

Choose a reason for hiding this comment

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

Bug: The regex in preReleaseCommand for updating ModuleVersion expects a single space, but the target .psd1 files use multiple spaces, causing the version update to fail silently.
Severity: HIGH

Suggested Fix

Update the regex pattern in the preReleaseCommand to account for variable whitespace. Change "ModuleVersion = '.*'" to "ModuleVersion\s+= '.*'" to correctly match the ModuleVersion line regardless of the number of spaces.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: .craft.yml#L4-L9

Potential issue: The `preReleaseCommand` in `.craft.yml` uses a PowerShell `-replace`
command with the pattern `"ModuleVersion = '.*'"` to update the module version. However,
the target `.psd1` files format this line as `ModuleVersion        = '1.0.0'` with
multiple spaces for alignment. PowerShell's regex engine requires an exact match, so the
single space in the pattern does not match the multiple spaces in the file. As a result,
the replacement fails silently, and the module version is never updated from the
hardcoded `'1.0.0'`. This will cause all releases to be published with an incorrect,
static version number.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

preReleaseCommand: >-
pwsh -Command "
@('app-runner/SentryAppRunner.psd1', 'sentry-api-client/SentryApiClient.psd1') | ForEach-Object {
(Get-Content $_) -replace \"ModuleVersion = '.*'\", \"ModuleVersion = '$env:CRAFT_NEW_VERSION'\" | Set-Content $_
Copy link

Choose a reason for hiding this comment

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

Version regex won't match multi-space alignment in manifests

High Severity

The -replace regex pattern ModuleVersion = '.*' expects a single space between ModuleVersion and =, but both .psd1 files use multiple spaces for column alignment (e.g., ModuleVersion = '1.0.0'). The regex won't match, so the preReleaseCommand will silently fail to update the version, and every release will ship with the hardcoded 1.0.0 version.

Fix in Cursor Fix in Web

@('app-runner/SentryAppRunner.psd1', 'sentry-api-client/SentryApiClient.psd1') | ForEach-Object {
(Get-Content $_) -replace \"ModuleVersion = '.*'\", \"ModuleVersion = '$env:CRAFT_NEW_VERSION'\" | Set-Content $_
}
"
Copy link

Choose a reason for hiding this comment

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

Shell expansion corrupts PowerShell variables in preReleaseCommand

High Severity

The preReleaseCommand wraps the PowerShell script in bash double quotes (pwsh -Command "..."). Since YAML >- block scalars preserve backslashes literally, the \" become escaped quotes in bash, keeping the content inside a double-quoted shell context. This means bash expands $_ (to bash's last argument, not PowerShell's pipeline variable) and $env (likely empty, turning $env:CRAFT_NEW_VERSION into the literal string :CRAFT_NEW_VERSION) before PowerShell ever sees them. The version replacement would silently produce incorrect results.

Fix in Cursor Fix in Web

@limbonaut
Copy link
Collaborator

Bots are not happy.

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