Repository: semantic-release/gitlab (js)

Issue:
asset url containing ${nextRelease.version} not working/expanded
I would like to create version dependent `url`s as release assets pointing to the specific file on an other filehosting server.

```json
["@semantic-release/gitlab", {
      "assets": [
          {"url": "http://fileserver/${nextRelease.version}/update.zip", "label": "update file", "type": "other"}
      ]
}]
```

The release page nevertheless will contain the following link:
```
http://fileserver/$%7BnextRelease.version%7D/update.zip
```

For the asset label that seems to work as the [documentation suggests](https://github.com/semantic-release/gitlab#usage), e.g.
```json
{"path": "dist/asset.min.js", "label": "v${nextRelease.version}.js"}
```

But why not for the `url`?

Pull request:
Allow templating
I added templating functioniality to `url`, `type` and ` filepath` like already done in #365 for `label`.
Closes #406 

Hope you like it (:

Patch:
diff --git a/README.md b/README.md
index 0ce8222..44d9b47 100644
--- a/README.md
+++ b/README.md
@@ -97,10 +97,10 @@ Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array`
 | Property | Description                                                                                                 | Default                              |
 | -------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------ |
 | `path`   | **Required**, unless `url` is set. A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload.    | -                                    |
-| `url`    | Alternative to setting `path` this provides the ability to add links to releases, e.g. URLs to container images.                           | -                                    |
-| `label`  | Short description of the file displayed on the GitLab release. Can be dynamically adjusted with [Lodash template](https://lodash.com/docs#template). Allows same variables as [`successComment`](#successComment). Ignored if `path` matches more than one file. | File name extracted from the `path`. |
-| `type` | Asset type displayed on the GitLab release. Can be `runbook`, `package`, `image` and `other` (see official documents on [release assets](https://docs.gitlab.com/ee/user/project/releases/#release-assets)). | `other` |
-| `filepath` | A filepath for creating a permalink pointing to the asset (requires GitLab 12.9+, see official documents on [permanent links](https://docs.gitlab.com/ee/user/project/releases/#permanent-links-to-release-assets)). Ignored if `path` matches more than one file. | - |
+| `url`    | Alternative to setting `path` this provides the ability to add links to releases, e.g. URLs to container images. Supports [Lodash templating](https://lodash.com/docs#template).                           | -                                    |
+| `label`  | Short description of the file displayed on the GitLab release. Ignored if `path` matches more than one file. Supports [Lodash templating](https://lodash.com/docs#template). | File name extracted from the `path`. |
+| `type` | Asset type displayed on the GitLab release. Can be `runbook`, `package`, `image` and `other` (see official documents on [release assets](https://docs.gitlab.com/ee/user/project/releases/#release-assets)). Supports [Lodash templating](https://lodash.com/docs#template). | `other` |
+| `filepath` | A filepath for creating a permalink pointing to the asset (requires GitLab 12.9+, see official documents on [permanent links](https://docs.gitlab.com/ee/user/project/releases/#permanent-links-to-release-assets)). Ignored if `path` matches more than one file. Supports [Lodash templating](https://lodash.com/docs#template). | - |
 
 Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
 can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together
diff --git a/lib/publish.js b/lib/publish.js
index eb2c408..59f5f65 100644
--- a/lib/publish.js
+++ b/lib/publish.js
@@ -44,9 +44,11 @@ module.exports = async (pluginConfig, context) => {
 
     await Promise.all(
       allAssets.map(async (asset) => {
-        const {path, type, filepath} = isPlainObject(asset) ? asset : {path: asset};
+        const {path} = isPlainObject(asset) ? asset : {path: asset};
+        const _url = asset.url ? template(asset.url)(context) : undefined;
         const label = asset.label ? template(asset.label)(context) : undefined;
-        const _url = asset.url;
+        const type = asset.type ? template(asset.type)(context) : undefined;
+        const filepath = asset.filepath ? template(asset.filepath)(context) : undefined;
         if (_url) {
           assetsList.push({label, rawUrl: _url, type, filepath});
           debug('use link from release setting: %s', _url);


Test patch:
diff --git a/test/publish.test.js b/test/publish.test.js
index 2fa7d98..7946bef 100644
--- a/test/publish.test.js
+++ b/test/publish.test.js
@@ -176,6 +176,68 @@ test.serial('Publish a release with an asset with a template label', async (t) =
   t.true(gitlab.isDone());
 });
 
+test.serial('Publish a release (with an link) with variables', async (t) => {
+  process.env.TYPE = 'other';
+  process.env.FILEPATH = '/dist/file.css';
+  const cwd = 'test/fixtures/files';
+  const owner = 'test_user';
+  const repo = 'test_repo';
+  const env = {GITLAB_TOKEN: 'gitlab_token'};
+  const nextRelease = {gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body', version: '1.0.0'};
+  const options = {repositoryUrl: `https://gitlab.com/${owner}/${repo}.git`};
+  const encodedRepoId = encodeURIComponent(`${owner}/${repo}`);
+  const encodedGitTag = encodeURIComponent(nextRelease.gitTag);
+  const uploaded = {url: '/uploads/file.css', alt: 'file.css'};
+  const assets = [
+    {
+      label: `README-v\${nextRelease.version}.md`,
+      type: `\${process.env.TYPE}`,
+      url: `https://gitlab.com/gitlab-org/gitlab/-/blob/master/README-v\${nextRelease.version}.md`,
+    },
+    {
+      label: 'file.css',
+      path: 'file.css',
+      type: 'other',
+      filepath: `\${process.env.FILEPATH}`,
+    },
+  ];
+  const gitlab = authenticate(env)
+    .post(`/projects/${encodedRepoId}/releases`, {
+      tag_name: nextRelease.gitTag,
+      description: nextRelease.notes,
+      assets: {
+        links: [
+          {
+            name: 'README-v1.0.0.md',
+            url: 'https://gitlab.com/gitlab-org/gitlab/-/blob/master/README-v1.0.0.md',
+            link_type: 'other',
+          },
+          {
+            name: 'file.css',
+            url: `https://gitlab.com/${owner}/${repo}${uploaded.url}`,
+            link_type: 'other',
+            filepath: '/dist/file.css',
+          },
+        ],
+      },
+    })
+    .reply(200);
+
+  const gitlabUpload = authenticate(env)
+    .post(`/projects/${encodedRepoId}/uploads`, /filename="file.css"/gm)
+    .reply(200, uploaded);
+  const result = await publish({assets}, {env, cwd, options, nextRelease, logger: t.context.logger});
+
+  t.is(result.url, `https://gitlab.com/${owner}/${repo}/-/releases/${encodedGitTag}`);
+  t.deepEqual(t.context.log.args[0], ['Uploaded file: %s', uploaded.url]);
+  t.deepEqual(t.context.log.args[1], ['Published GitLab release: %s', nextRelease.gitTag]);
+  t.true(gitlabUpload.isDone());
+  t.true(gitlab.isDone());
+
+  delete process.env.TYPE;
+  delete process.env.FILEPATH;
+});
+
 test.serial('Publish a release with a milestone', async (t) => {
   const owner = 'test_user';
   const repo = 'test_repo';