tl;dr
PowerShell interprets $FILE_NAME.zip
as trying to get the value of a property named zip
of the object stored in variable $FILE_NAME
.
To treat the .zip
part literally, as you intend, you have the following options:
Use "$FILE_NAME.zip"
, i.e. explicitly make it an expandable (double-quoted) string
Inside "..."
, .
has no special meaning, except if inside an embedded subexpression ($(...)
) - see this answer for a systematic overview of the interpolation rules of expandable strings.
Even selective double-quoting would work - $FILE_NAME".zip"
- but such compound string arguments are tricky in PowerShell, because they only work as intended if the first component is unquoted - see this answer.
Use $FILE_NAME`.zip
, i.e. escape the .
character, using `
, the so-called backtick, PowerShell's escape character.
If appropriate, use .\$FILE_NAME.zip
- starting the argument with a character other than $
in essence treats it as if it were enclosed in "..."
.
Therefore, using the first option (note the "$FILE_NAME.zip"
at the end):
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: build dists
run: |
curl.exe -i --user "${{secrets.User}}:${{secrets.Password}}" -H "X-Checksum-Md5:$MD5SUM" -X PUT "${{ env.URL }}\${{ env.PATH }}\$FILE_NAME\${{ github.sha }}.zip" --upload-file "$FILE_NAME.zip"
Background information:
$FILE_NAME.zip
is parsed as a property access; that is, an attempt is made to retrieve the value of a property named zip
on whatever object the $FILE_NAME
variable contains.
Since a string object has no .zip
property, PowerShell returns $null
, which, when passed as an argument to an external program such as curl
, in effect passes no argument at all, which explains the errors you saw.
Note that if your argument didn't start with $FILE_NAME
, it would implicitly have been treated like an expandable string; therefore, an alternative to "$FILE_NAME.zip"
is to use .\$FILE_NAME.zip
in this case.
The rules for how PowerShell interprets unquoted tokens as command arguments are complex - see this answer for a systematic overview.