Skip to content

Fix attach-release-zip workflow: broken composer auth + packaged empty dist/ - #291

Closed
Castellon-ACM wants to merge 10 commits into
trunkfrom
ci/attach-release-zip
Closed

Fix attach-release-zip workflow: broken composer auth + packaged empty dist/#291
Castellon-ACM wants to merge 10 commits into
trunkfrom
ci/attach-release-zip

Conversation

@Castellon-ACM

Copy link
Copy Markdown
Contributor

Summary

PR #290 merged a workflow that turned out to be broken end-to-end — verified live against the real 1.5.2 release via the new workflow_dispatch trigger this PR adds:

  • Real bug (fatal): wp package install failed every time with Your github oauth token for github.com contains invalid characters. Root cause: shivammathur/setup-php writes a github-oauth token into Composer's global auth.json (to dodge GitHub API rate limits during its own setup) that this Composer version's own validation rejects as malformed. Fixed by unsetting that config entry before installing dist-archive-command — this repo's public package install doesn't need authentication anyway.
  • Real bug (packaging): the produced zip contained an empty frontblocks/dist/ folder. wp dist-archive's own --create-target-dir output (./dist) lived inside the plugin directory being archived, and .distignore has no entry for it, so it got swept into the zip. Fixed by building into ${{ runner.temp }}/dist, outside the checkout entirely.
  • Adds workflow_dispatch with a tag_name input so this workflow can be tested against an already-published release without cutting a new one — this is how both bugs above were actually found and confirmed fixed, rather than discovered on the next real release.

Test plan

  • Dispatched manually against the real 1.5.2 release, iterated until green
  • Downloaded the resulting frontblocks-1.5.2.zip asset and confirmed: 231 files, single top-level frontblocks/ folder, no dist/ entry, no composer.json/package.json/node_modules/tests//.github

davidperezgar and others added 10 commits September 7, 2026 08:09
Builds the production zip with wp-cli's dist-archive-command (the same
tool used for manual releases, honouring .distignore) and uploads it as
an asset on the GitHub Release once published, so the plugin can be
installed straight from the Releases page.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
--filename-format is silently ignored when <target> names a file, so
switch to a directory target with --create-target-dir. Also bumps
dist-archive-command to ^3.0 (a tagged release), the minimum version
that supports --filename-format.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The PR's own test plan flagged this as unverified: nothing exercises
the workflow end to end without publishing a real release. A manual
tag_name input lets it be re-run against an already-published release
(re-checking out that tag) to confirm the zip actually gets attached.

Also drops the now-redundant mkdir -p dist: --create-target-dir already
creates the target directory.
wp package install (via Composer) auto-detects the GitHub CLI that
hosted runners pre-authenticate, and using it fails with "Your github
oauth token for github.com contains invalid characters" — confirmed via
a debug run that none of GITHUB_TOKEN/GH_TOKEN/COMPOSER_AUTH were set as
env vars, so the token came from gh's own stored auth, not the job env.
dist-archive-command is a public package, so forcing anonymous
Composer API access for this one step is safe.
COMPOSER_AUTH='{}' alone didn't fix it — Composer calls \`gh auth
token\` directly regardless of COMPOSER_AUTH when gh is on PATH. The
runner's pre-authenticated gh CLI returns something Composer's own
validation rejects. Logging gh out for this one step removes that
stored auth so Composer falls back to unauthenticated (fine for a
public package); the final upload step re-authenticates gh explicitly
via GH_TOKEN regardless.
…ist/

wp dist-archive's own --create-target-dir target (./dist) lived inside
the plugin directory being archived, and .distignore has no entry for
it, so the resulting zip packaged an empty frontblocks/dist/ folder —
confirmed by inspecting the zip uploaded to the 1.5.2 release. Building
into runner.temp instead keeps the archive output entirely outside the
source tree being walked.
The real culprit (confirmed via debug output, since gh CLI was already
logged out with no effect): shivammathur/setup-php writes a
github-oauth token into ~/.composer/auth.json to avoid GitHub API rate
limits during its own setup, and this Composer version rejects that
token as malformed. Unsetting the global config entry (not gh auth,
which was a dead end) fixes it — verified against a real published
release.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@Castellon-ACM

Copy link
Copy Markdown
Contributor Author

Superseded by #292 — the diff here got polluted with a bogus conflict against trunk (the squash-merge of #290 diverged the branch history from a stale base). Opening a clean PR from a fresh branch instead.

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