Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
minVersion: '2.21.0'
changelog:
policy: auto
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

}
"
Comment on lines +4 to +9
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

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

targets:
- name: github
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: Version to release (or "auto")
required: false
force:
description: Force a release even when there are release-blockers
type: boolean
default: false

permissions: read-all

jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_RELEASE_PAT }}
- uses: getsentry/craft@v2
with:
version: ${{ inputs.version }}
force: ${{ inputs.force }}
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## Unreleased

- Initial release.