Skip to content

fix: print the release version - #3023

Merged
soyuka merged 3 commits into
api-platform:mainfrom
BenMacha:fix-installer-version
Nov 24, 2026
Merged

soyuka merged 3 commits into
api-platform:mainfrom
BenMacha:fix-installer-version

Conversation

@BenMacha

@BenMacha BenMacha commented Nov 1, 2026

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Released binaries always print API Platform dev: InstallerCommand::VERSION is @package_version@, a placeholder box used to replace, but scripts/build-phar.php never substitutes it. The build now replaces it with the version given as second argument, then INSTALLER_VERSION, then git describe --tags (still dev when none is available). The release workflow passes the tag, and its smoke test now fails if --version does not print it.

scripts/build-phar.php never replaced the @package_version@ placeholder
(box used to), so released binaries answered `--version` with "dev".
The build now substitutes it with the version passed as second argument,
INSTALLER_VERSION or `git describe --tags`; the release passes the tag and
its smoke test checks the binary reports it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T08:09:58.393996Z 81cc1b4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81cc1b47c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/build-phar.php Outdated
$phar->addFromString($relative, read_file($file->getPathname()));
$contents = read_file($file->getPathname());
if ('' !== $version && 'src/InstallerCommand.php' === $relative) {
$contents = str_replace('@package_version@', $version, $contents);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Encode the release version before inserting it into PHP

The release workflow accepts every v* tag, but this replacement is inserted verbatim into the single-quoted InstallerCommand::VERSION literal. A valid tag such as v';function&__destruct(){file_put_contents('pwn',1);}#x closes that literal, adds a destructor, and comments out the original trailing quote; the resulting PHAR runs tag-controlled PHP when the command object is destroyed. Encode the version as a PHP string or reject tags outside a strict version pattern before replacing the placeholder.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/release.yml Outdated

- name: Build PHAR
run: php -d phar.readonly=0 scripts/build-phar.php dist/api-platform.phar
run: php -d phar.readonly=0 scripts/build-phar.php dist/api-platform.phar "${{ github.ref_name }}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass the tag as data instead of interpolating it into Bash

The release workflow accepts every v* tag, and a valid tag such as v$(id) is substituted into the run script before Bash parses it, so command substitution executes despite the surrounding double quotes. A tag pusher can therefore run commands on the release runners; the build job grants contents: write and exposes GITHUB_TOKEN, and the smoke-test step repeats the same interpolation. Pass the ref through an environment variable and use it as a shell argument in both steps.

Useful? React with 👍 / 👎.

@soyuka
soyuka merged commit 8e876e8 into api-platform:main Nov 24, 2026
6 of 7 checks passed
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