Skip to content

Commit

Permalink
fix: #24 drop GitHub API in favor of URL redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiraces-plain committed Feb 15, 2023
1 parent 280eabe commit 9f93795
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 99 deletions.
68 changes: 2 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-devops-bicep-task",
"version": "0.4.4",
"version": "0.4.5",
"description": "Tasks for installing Bicep CLI and running Bicep CLI build commands",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -38,7 +38,6 @@
"homepage": "https://github.com/piraces/azure-devops-bicep-task#readme",
"dependencies": {
"axios": "^0.27.2",
"axios-retry": "^3.4.0",
"azure-pipelines-task-lib": "^4.2.0",
"azure-pipelines-tool-lib": "^2.0.0-preview",
"glob": "^8.1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/decompile/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 0,
"Minor": 4,
"Patch": 4
"Patch": 5
},
"instanceNameFormat": "Run Bicep CLI decompile command",
"inputs": [
Expand Down
34 changes: 7 additions & 27 deletions src/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,7 @@ import { platform, arch } from 'os';
import * as taskLib from 'azure-pipelines-task-lib/task';
import * as toolLib from 'azure-pipelines-tool-lib/tool';
import { ClientRequest } from 'http';
import axios, { AxiosError } from 'axios';
import axiosRetry from 'axios-retry';

axiosRetry(axios,
{
retries: 3,
retryCondition: (error: AxiosError) => {
if (!error.response || error.response.status >= 400) {
if (error.response) {
taskLib.debug(`Retrying request with status code '${error.response.status}'.`);
taskLib.debug(`Response received: '${JSON.stringify(error.response)}'.`);
}
return true;
}
return false;
}
});
import axios from 'axios';

export function getDownloadUrl(version: string): string {
const agentPlatform = platform();
Expand Down Expand Up @@ -51,13 +35,9 @@ export function getDownloadUrl(version: string): string {

export async function getLatestVersionTag(): Promise<string> {
return await axios
.get('https://api.github.com/repos/Azure/Bicep/releases/latest', {
headers: {
'User-Agent': 'piraces',
},
})
.then(function (response: { data: { tag_name: string } }) {
return response.data.tag_name.replace('v', '');
.get('https://github.com/azure/bicep/releases/latest')
.then(function (response) {
return response.request.path.split('/')[5].replace('v', '');
})
.catch(function (error: {
message: string;
Expand All @@ -69,15 +49,15 @@ export async function getLatestVersionTag(): Promise<string> {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
throw new Error(
`[FATAL] Error while retrieving latest version tag: '${error.message}'.\nResponse: \n-Data: '${JSON.stringify(error.response.data)}' \n-Status: '${error.response.status}' \n-Headers: '${JSON.stringify(error.response.headers)}'`,
`[FATAL] Error while retrieving latest version tag: '${error.message}'.`,
);
} else if (error.request) {
throw new Error(
`[FATAL] Error while retrieving latest version tag: '${error.message}'.\nRequest: '${JSON.stringify(error.request)}'\nConfig: '${error.config}'`,
`[FATAL] Error while retrieving latest version tag: '${error.message}'.`,
);
} else {
throw new Error(
`[FATAL] Error while retrieving latest version tag: '${error.message}'.\nConfig: '${error.config}'`,
`[FATAL] Error while retrieving latest version tag: '${error.message}'.`,
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/install/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 0,
"Minor": 4,
"Patch": 4
"Patch": 5
},
"instanceNameFormat": "Install Bicep CLI",
"inputs": [
Expand Down
2 changes: 1 addition & 1 deletion src/run/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 0,
"Minor": 4,
"Patch": 4
"Patch": 5
},
"instanceNameFormat": "Run Bicep CLI build command",
"inputs": [
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifestVersion": 1,
"id": "bicep-tasks",
"version": "0.4.4",
"version": "0.4.5",
"name": "Bicep Tasks",
"publisher": "piraces",
"description": "Provides Azure DevOps tasks to install and run Microsoft Bicep CLI commands (cross-platform)",
Expand Down

0 comments on commit 9f93795

Please sign in to comment.