mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-30 19:54:27 +01:00
* Fixes #43: OpenTofu 1.6 can no longer be downloaded Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com> * More sane self-test Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com> --------- Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
This commit is contained in:
1 parent
12f4debbf6
commit
592200bd4b
6 files changed
+177
-398
No files matched your search
+11
-12
@@ -4,16 +4,16 @@
|
||||
*/
|
||||
|
||||
class Build {
|
||||
constructor (name, url) {
|
||||
constructor (version, name) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.url = 'https://github.com/opentofu/opentofu/releases/download/v' + version + '/' + name;
|
||||
}
|
||||
}
|
||||
|
||||
class Release {
|
||||
constructor (releaseMeta) {
|
||||
this.version = releaseMeta.tag_name.replace('v', '');
|
||||
this.builds = releaseMeta.assets.map(asset => new Build(asset.name, asset.browser_download_url));
|
||||
this.version = releaseMeta.id.replace('v', '');
|
||||
this.builds = releaseMeta.files.map(asset => new Build(this.version, asset));
|
||||
}
|
||||
|
||||
getBuild (platform, arch) {
|
||||
@@ -28,17 +28,12 @@ class Release {
|
||||
* @return {Array<Release>} Releases.
|
||||
*/
|
||||
async function fetchReleases (githubToken) {
|
||||
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
||||
const url = 'https://get.opentofu.org/tofu/api.json';
|
||||
|
||||
const headers = {
|
||||
Accept: 'application/vnd.github+json',
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
Accept: 'application/json'
|
||||
};
|
||||
|
||||
if (githubToken) {
|
||||
headers.Authorization = `Bearer ${githubToken}`;
|
||||
}
|
||||
|
||||
const resp = await fetch(url, {
|
||||
headers
|
||||
});
|
||||
@@ -48,8 +43,12 @@ async function fetchReleases (githubToken) {
|
||||
}
|
||||
|
||||
const releasesMeta = await resp.json();
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
const versions = releasesMeta.versions;
|
||||
|
||||
return releasesMeta.map(releaseMeta => new Release(releaseMeta));
|
||||
return versions.map(releaseMeta => new Release(releaseMeta));
|
||||
}
|
||||
|
||||
const semver = require('semver');
|
||||
|
||||
Reference in new issue
Block a user