Search code examples
appveyor

Different naming artifacts on appveyor when tag pushed?


I have this pattern in appveyor.yml:

  - path: Foo\bin\$(configuration)
    name: Foo_%APPVEYOR_BUILD_VERSION%
    type: zip

When i push some regular commit, i get artifact Foo_123_master.zip.

Want Foo_1.4.8.zip, when push release tag 1.4.8.

Appveyor have %APPVEYOR_REPO_TAG_NAME% environment variable, but how to setup artifacts to different naming on regular build and tag pushed build?


Solution

  • You can introduce another environment variable and set it depending on the build type, for example:

    init:
    - ps: |
        $env:artifact_suffix = $env:APPVEYOR_BUILD_VERSION
        if ($env:APPVEYOR_REPO_TAG -eq 'true') {
          $env:artifact_suffix = $env:APPVEYOR_REPO_TAG_NAME
        }
    

    and then in artifacts section:

      - path: Foo\bin\$(configuration)
        name: Foo_%artifact_suffix%
        type: zip