Installed version of wrangler not being used with v3.7.0 using yarn v1.22.22 in CI
i’m very excited for the changes introduced in v3.7.0 to use existing wrangler installation when appropriate (from #271). my app relies on getPlatformProxy so it cannot be deployed with any version of wrangler that doesn’t include that API. however, in my case, the logic to check that existing install and version if somehow falling through to the ⚠️ Wrangler not found or version is incompatible. Installing... fallback logic.
here is my output from the workflow run, which shows that i am using yarn v1.22.22 and shows that /usr/local/bin/yarn wrangler --version, as invoked by wrangler-action, is returning the version number (3.63.2) correctly:
Run cloudflare/[email protected]
with:
apiToken: ***
quiet: false
🔍 Checking for existing Wrangler installation
/usr/local/bin/yarn wrangler --version
yarn run v1.22.22
$ /home/runner/work/outlyne/outlyne/node_modules/.bin/wrangler --version
3.63.2
Done in 0.57s.
⚠️ Wrangler not found or version is incompatible. Installing...
📥 Installing Wrangler
/usr/local/bin/yarn add [email protected]
yarn add v1.22.22
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
my hypothesis is that the issue is due to the fallback regex starting with the “start of string” token (/^):
stdout.match(/wrangler (\d+\.\d+\.\d+)/) ?? stdout.match(/^(\d+\.\d+\.\d+)/);
i’m not sure how stdout is derived, but if it includes anything before the version output (e.g. \n3.63.2, or even /home/runner/work/outlyne/outlyne/node_modules/.bin/wrangler --version\n3.63.2), the regex won’t match it.
the most obvious solution, then, is to use multi-line mode so that ^ matches the start of every line as well as the start of the string:
const versionMatch =
stdout.match(/wrangler (\d+\.\d+\.\d+)/) ??
stdout.match(/^(\d+\.\d+\.\d+)/);
in case it’s helpful, this is my yaml from the workflow file itself:
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, vitest]
# only deploy main branch on pushes
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: yarn
cache-dependency-path: ./yarn.lock
node-version: 20
- name: 📥 Install deps
run: yarn
- name: 🚀 Deploy Production
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}