magefile/mage-action

incorrect release URL for macOS (darwin) runners

Opened this issue · 5 comments

Support guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

When using the action on a macOS runner it will fail to download the release binary.

Expected behaviour

For the action to download the correct binary.

Actual behaviour

Run magefile/mage-action@v3
Mage version found: v1.1[5](https://github.com/na4ma4/mage-macos-issue/actions/runs/9638247781/job/26578654439#step:4:6).0
Downloading https://github.com/magefile/mage/releases/download/v1.15.0/mage_1.15.0_macOS-ARM[6](https://github.com/na4ma4/mage-macos-issue/actions/runs/9638247781/job/26578654439#step:4:7)4.tar.gz...
Error: Unexpected HTTP response: 404

Steps to reproduce

  1. Use magefile/mage-action in workflow.
  2. runs-on: macos-latest
  3. step will fail

Repository URL

https://github.com/na4ma4/mage-macos-issue

Workflow run URL

https://github.com/na4ma4/mage-macos-issue/actions/runs/9638284485

YAML workflow

name: "GoReleaser"

on:
  push:
  workflow_dispatch:


jobs:
  mage-test:
    name: "Mage Test: ${{ matrix.os }}"
    strategy:
      fail-fast: false
      matrix:
        os: ['macos-latest', 'ubuntu-latest']
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        cache: false
        go-version: ^1
      id: go

    - name: Run Mage
      uses: magefile/mage-action@v3

Workflow logs

logs_25224800589.zip

Additional info

No response

Is it still happening? I'm not able to repro with all macOS runners available: https://github.com/magefile/mage-action/actions/runs/11550066329?pr=341

Interesting that your runs seem to pull the mage binary from the actions cache but when I test it, it's downloading it from the repo artifacts.

It still happens for me, I wonder how it got downloaded into the cache the first time for your runs.

I'm looking through previous runs in this repository, but here's the relevant line

Ok, so if I make a runner for macos-13 (which is x64) and run it first, it caches the binary, then when the macos-latest runs it uses the cached binary and works.

So the issue is that it's trying to download ARM64 for macos when it needs to use x64.

https://github.com/magefile/mage-action/blob/master/src/installer.ts#L103-L108

const getFilename = (semver: string): string => {
  const platform: string = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'macOS' : 'Linux';
  const arch: string = osArch == 'x64' ? '64bit' : osArch == 'arm64' ? 'ARM64' : '32bit';
  const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
  return util.format('mage_%s_%s-%s.%s', semver, platform, arch, ext);
};

might need something like

const getFilename = (semver: string): string => {
  const platform: string = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'macOS' : 'Linux';
  const arch: string = osPlat == 'darwin' && osArch == 'arm64' ? '64bit' : osArch == 'x64' ? '64bit' : osArch == 'arm64' ? 'ARM64' : '32bit';
  const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
  return util.format('mage_%s_%s-%s.%s', semver, platform, arch, ext);
};