Reference: https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image/
GitHub hosted runners for `macos-latest` are automatically being upgraded to macOS 14 and arm64 architecture machines. Any workflows that are using the upgraded runner can return an error such as:
```
Error: Terraform version 0.12.* not available for darwin and arm64
```
This adds special case logic to automatically fallback to darwin/amd64 when darwin/arm64 is detected and the version is below 1.0.2, which is the first version that had darwin/arm64 release assets. macOS should emulate and run the amd64 binaries until Apple or GitHub removes the emulation support.
If you don't specify the TF_CLI_CONFIG_FILE environment variable, the
default config is written to $HOME directory, which could theoretically
be shared by multiple runners when using self-hosted runners.
When TF_CLI_CONFIG_FILE is _not_ in use, I replaced the usage of
$HOME with the directory $RUNNER_TEMP, whose setup/cleanup is
managed by the runner framework and exported a TF_CLI_CONFIG_FILE.
On Windows runners, extracting the downloaded CLI zip file was failing because the file didn't have a .zip extension. This commit attempts to solve the problem by adding the extension to the downloaded file before extraction.
That allows to install for example the latest bug-fix version of
terraform 1.12.* even if 1.13 is already installed.
Co-authored-by: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com>