Skip to content

Commit

Permalink
feat: allow loading variable from release url
Browse files Browse the repository at this point in the history
  • Loading branch information
awcjack committed Apr 17, 2022
1 parent 4e64262 commit fdc3b0f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ module.exports = async (pluginConfig, context) => {
await Promise.all(
allAssets.map(async asset => {
const {path, label, type, filepath} = isPlainObject(asset) ? asset : {path: asset};
const _url = asset.url;
let _url = asset.url;
if (_url) {
// Allow loading variable from process.env load CI_JOB_ID for attaching CI artifact
const matchedVariables = _url.match(/\${[a-zA-Z].*}/);
if (matchedVariables) {
for (const matchedVariable of matchedVariables) {
const variableName = matchedVariable.slice(2, -1);
if (process.env[variableName]) {
_url = _url.replace(matchedVariable, process.env[variableName]);
}
}
}

assetsList.push({label, rawUrl: _url, type, filepath});
debug('use link from release setting: %s', _url);
} else {
Expand Down

0 comments on commit fdc3b0f

Please sign in to comment.