Artifact path not identified when set dynamically

Summary

Unable to set the artifact path dynamically on gitlab-ci.yml.

Steps to reproduce

Build an image along the following lines

image: node:latest

stages:
  - build

before_script:
    - rm -rf /home/gitlab-runner/.yarn
    - apt-get update && apt-get install -yqq jq
    - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
    - export PATH="$HOME/.yarn/bin:$PATH"
    - yarn config set cache-folder $(pwd)/.yarn-cache
    - yarn install
    - apt-get update && apt-get install -yqq jq
    - export NAME_OF_ARTIFACT=$(cat package.json | jq -r .name)"_"$(cat package.json | jq -r .version)".zip"

prod_build:
  stage: build
  tags:
  - autoscale
  script: 
    - echo $NAME_OF_ARTIFACT
    - yarn run build
  artifacts:
    paths:
    - dist/$NAME_OF_ARTIFACT

What is the current bug behavior?

The path is not identified and thus results in the following error

Uploading artifacts...
WARNING: : no matching files   

What is the expected correct behavior?

The right folder is identified

Assignee Loading
Time tracking Loading