Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opentofu/setup-opentofu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.4
Choose a base ref
...
head repository: opentofu/setup-opentofu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.5
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Dec 10, 2024

  1. Fixes #43: OpenTofu 1.6 can no longer be downloaded (#44)

    * 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>
    abstractionfactory authored Dec 10, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    592200b View commit details
Showing with 177 additions and 398 deletions.
  1. +1 −1 .github/workflows/setup-tofu.yml
  2. +13 −14 dist/index.js
  3. +11 −12 lib/releases.js
  4. +2 −2 lib/setup-tofu.js
  5. +130 −355 lib/test/releases.test.js
  6. +20 −14 package-lock.json
2 changes: 1 addition & 1 deletion .github/workflows/setup-tofu.yml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-versions: [1.6.0-alpha1, latest]
tofu-versions: [1.6.0, latest]
tofu-wrapper: [true, false]
steps:
- name: Checkout
27 changes: 13 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -10,16 +10,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) {
@@ -34,17 +34,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
});
@@ -54,8 +49,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 = __nccwpck_require__(1383);
@@ -168,7 +167,7 @@ async function downloadAndExtractCLI (url) {
if (os.platform().startsWith('win')) {
core.debug(`OpenTofu CLI Download Path is ${pathToCLIZip}`);
const fixedPathToCLIZip = `${pathToCLIZip}.zip`;
io.mv(pathToCLIZip, fixedPathToCLIZip);
await io.mv(pathToCLIZip, fixedPathToCLIZip);
core.debug(`Moved download to ${fixedPathToCLIZip}`);
pathToCLI = await tc.extractZip(fixedPathToCLIZip);
} else {
@@ -225,7 +224,7 @@ async function addCredentials (credentialsHostname, credentialsToken, osPlat) {
credentials "${credentialsHostname}" {
token = "${credentialsToken}"
}`.trim();
// eslint-enable
// eslint-enable

// default to OS-specific path
let credsFile = osPlat === 'win32'
23 changes: 11 additions & 12 deletions lib/releases.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 2 additions & 2 deletions lib/setup-tofu.js
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ async function downloadAndExtractCLI (url) {
if (os.platform().startsWith('win')) {
core.debug(`OpenTofu CLI Download Path is ${pathToCLIZip}`);
const fixedPathToCLIZip = `${pathToCLIZip}.zip`;
io.mv(pathToCLIZip, fixedPathToCLIZip);
await io.mv(pathToCLIZip, fixedPathToCLIZip);
core.debug(`Moved download to ${fixedPathToCLIZip}`);
pathToCLI = await tc.extractZip(fixedPathToCLIZip);
} else {
@@ -105,7 +105,7 @@ async function addCredentials (credentialsHostname, credentialsToken, osPlat) {
credentials "${credentialsHostname}" {
token = "${credentialsToken}"
}`.trim();
// eslint-enable
// eslint-enable

// default to OS-specific path
let credsFile = osPlat === 'win32'
485 changes: 130 additions & 355 deletions lib/test/releases.test.js

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions package-lock.json