diff --git a/.github/workflows/setup-tofu.yml b/.github/workflows/setup-tofu.yml index 3f667fe..a38a6b4 100644 --- a/.github/workflows/setup-tofu.yml +++ b/.github/workflows/setup-tofu.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index 3a4f113..578bb62 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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} 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' diff --git a/lib/releases.js b/lib/releases.js index 5643408..a7eb082 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -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} 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'); diff --git a/lib/setup-tofu.js b/lib/setup-tofu.js index 37f56e1..0eb7aa1 100644 --- a/lib/setup-tofu.js +++ b/lib/setup-tofu.js @@ -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' diff --git a/lib/test/releases.test.js b/lib/test/releases.test.js index 420d7ae..5ad140e 100644 --- a/lib/test/releases.test.js +++ b/lib/test/releases.test.js @@ -3,362 +3,133 @@ const pkg = require('../releases'); describe('getRelease', () => { function mockFetchReleases () { const mockReleasesMeta = [{ - tag_name: 'v1.7.0-alpha2', - assets: [{ - name: 'tofu_1.7.0-alpha2_386.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.apk' - }, { - name: 'tofu_1.7.0-alpha2_386.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.deb' - }, { - name: 'tofu_1.7.0-alpha2_386.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_386.rpm' - }, { - name: 'tofu_1.7.0-alpha2_amd64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.apk' - }, { - name: 'tofu_1.7.0-alpha2_amd64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.deb' - }, { - name: 'tofu_1.7.0-alpha2_amd64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_amd64.rpm' - }, { - name: 'tofu_1.7.0-alpha2_arm.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.apk' - }, { - name: 'tofu_1.7.0-alpha2_arm.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.deb' - }, { - name: 'tofu_1.7.0-alpha2_arm.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm.rpm' - }, { - name: 'tofu_1.7.0-alpha2_arm64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.apk' - }, { - name: 'tofu_1.7.0-alpha2_arm64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.deb' - }, { - name: 'tofu_1.7.0-alpha2_arm64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_arm64.rpm' - }, { - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_darwin_amd64.zip' - }, { - name: 'tofu_1.7.0-alpha2_darwin_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_darwin_arm64.zip' - }, { - name: 'tofu_1.7.0-alpha2_freebsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_386.zip' - }, { - name: 'tofu_1.7.0-alpha2_freebsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_amd64.zip' - }, { - name: 'tofu_1.7.0-alpha2_freebsd_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_freebsd_arm.zip' - }, { - name: 'tofu_1.7.0-alpha2_linux_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_386.zip' - }, { - name: 'tofu_1.7.0-alpha2_linux_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_amd64.zip' - }, { - name: 'tofu_1.7.0-alpha2_linux_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_arm.zip' - }, { - name: 'tofu_1.7.0-alpha2_linux_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_linux_arm64.zip' - }, { - name: 'tofu_1.7.0-alpha2_openbsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_openbsd_386.zip' - }, { - name: 'tofu_1.7.0-alpha2_openbsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_openbsd_amd64.zip' - }, { - name: 'tofu_1.7.0-alpha2_SHA256SUMS', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS' - }, { - name: 'tofu_1.7.0-alpha2_SHA256SUMS.pem', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS.pem' - }, { - name: 'tofu_1.7.0-alpha2_SHA256SUMS.sig', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_SHA256SUMS.sig' - }, { - name: 'tofu_1.7.0-alpha2_solaris_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_solaris_amd64.zip' - }, { - name: 'tofu_1.7.0-alpha2_windows_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_windows_386.zip' - }, { - name: 'tofu_1.7.0-alpha2_windows_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.7.0-alpha2/tofu_1.7.0-alpha2_windows_amd64.zip' - }] + id: 'v1.7.0-alpha2', + files: [ + 'tofu_1.7.0-alpha2_386.apk', + 'tofu_1.7.0-alpha2_386.deb', + 'tofu_1.7.0-alpha2_386.rpm', + 'tofu_1.7.0-alpha2_amd64.apk', + 'tofu_1.7.0-alpha2_amd64.deb', + 'tofu_1.7.0-alpha2_amd64.rpm', + 'tofu_1.7.0-alpha2_arm.apk', + 'tofu_1.7.0-alpha2_arm.deb', + 'tofu_1.7.0-alpha2_arm.rpm', + 'tofu_1.7.0-alpha2_arm64.apk', + 'tofu_1.7.0-alpha2_arm64.deb', + 'tofu_1.7.0-alpha2_arm64.rpm', + 'tofu_1.7.0-alpha2_darwin_arm64.zip', + 'tofu_1.7.0-alpha2_freebsd_386.zip', + 'tofu_1.7.0-alpha2_freebsd_amd64.zip', + 'tofu_1.7.0-alpha2_freebsd_arm.zip', + 'tofu_1.7.0-alpha2_linux_386.zip', + 'tofu_1.7.0-alpha2_linux_amd64.zip', + 'tofu_1.7.0-alpha2_linux_arm.zip', + 'tofu_1.7.0-alpha2_linux_arm64.zip', + 'tofu_1.7.0-alpha2_openbsd_386.zip', + 'tofu_1.7.0-alpha2_openbsd_amd64.zip', + 'tofu_1.7.0-alpha2_SHA256SUMS', + 'tofu_1.7.0-alpha2_SHA256SUMS.pem', + 'tofu_1.7.0-alpha2_SHA256SUMS.sig', + 'tofu_1.7.0-alpha2_solaris_amd64.zip', + 'tofu_1.7.0-alpha2_windows_386.zip', + 'tofu_1.7.0-alpha2_windows_amd64.zip' + ] }, { - tag_name: 'v1.6.0', - assets: [{ - name: 'tofu_1.6.0_386.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.apk' - }, { - name: 'tofu_1.6.0_386.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.deb' - }, { - name: 'tofu_1.6.0_386.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_386.rpm' - }, { - name: 'tofu_1.6.0_amd64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.apk' - }, { - name: 'tofu_1.6.0_amd64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.deb' - }, { - name: 'tofu_1.6.0_amd64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_amd64.rpm' - }, { - name: 'tofu_1.6.0_arm.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.apk' - }, { - name: 'tofu_1.6.0_arm.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.deb' - }, { - name: 'tofu_1.6.0_arm.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm.rpm' - }, { - name: 'tofu_1.6.0_arm64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.apk' - }, { - name: 'tofu_1.6.0_arm64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.deb' - }, { - name: 'tofu_1.6.0_arm64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_arm64.rpm' - }, { - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_darwin_amd64.zip' - }, { - name: 'tofu_1.6.0_darwin_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_darwin_arm64.zip' - }, { - name: 'tofu_1.6.0_freebsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_386.zip' - }, { - name: 'tofu_1.6.0_freebsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_amd64.zip' - }, { - name: 'tofu_1.6.0_freebsd_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_freebsd_arm.zip' - }, { - name: 'tofu_1.6.0_linux_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_386.zip' - }, { - name: 'tofu_1.6.0_linux_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_amd64.zip' - }, { - name: 'tofu_1.6.0_linux_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_arm.zip' - }, { - name: 'tofu_1.6.0_linux_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_linux_arm64.zip' - }, { - name: 'tofu_1.6.0_openbsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_openbsd_386.zip' - }, { - name: 'tofu_1.6.0_openbsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_openbsd_amd64.zip' - }, { - name: 'tofu_1.6.0_SHA256SUMS', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS' - }, { - name: 'tofu_1.6.0_SHA256SUMS.pem', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS.pem' - }, { - name: 'tofu_1.6.0_SHA256SUMS.sig', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_SHA256SUMS.sig' - }, { - name: 'tofu_1.6.0_solaris_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_solaris_amd64.zip' - }, { - name: 'tofu_1.6.0_windows_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_windows_386.zip' - }, { - name: 'tofu_1.6.0_windows_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0/tofu_1.6.0_windows_amd64.zip' - }] + id: 'v1.6.0', + files: [ + 'tofu_1.6.0_386.apk', + 'tofu_1.6.0_386.deb', + 'tofu_1.6.0_386.rpm', + 'tofu_1.6.0_amd64.apk', + 'tofu_1.6.0_amd64.deb', + 'tofu_1.6.0_amd64.rpm', + 'tofu_1.6.0_arm.apk', + 'tofu_1.6.0_arm.deb', + 'tofu_1.6.0_arm.rpm', + 'tofu_1.6.0_arm64.apk', + 'tofu_1.6.0_arm64.deb', + 'tofu_1.6.0_arm64.rpm', + 'tofu_1.6.0_darwin_arm64.zip', + 'tofu_1.6.0_freebsd_386.zip', + 'tofu_1.6.0_freebsd_amd64.zip', + 'tofu_1.6.0_freebsd_arm.zip', + 'tofu_1.6.0_linux_386.zip', + 'tofu_1.6.0_linux_amd64.zip', + 'tofu_1.6.0_linux_arm.zip', + 'tofu_1.6.0_linux_arm64.zip', + 'tofu_1.6.0_openbsd_386.zip', + 'tofu_1.6.0_openbsd_amd64.zip', + 'tofu_1.6.0_SHA256SUMS', + 'tofu_1.6.0_SHA256SUMS.pem', + 'tofu_1.6.0_SHA256SUMS.sig', + 'tofu_1.6.0_solaris_amd64.zip', + 'tofu_1.6.0_windows_386.zip', + 'tofu_1.6.0_windows_amd64.zip'] }, { - tag_name: 'v1.6.0-alpha2', - assets: [{ - name: 'tofu_1.6.0-alpha2_386.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_386.apk' - }, { - name: 'tofu_1.6.0-alpha2_386.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_386.deb' - }, { - name: 'tofu_1.6.0-alpha2_386.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_386.rpm' - }, { - name: 'tofu_1.6.0-alpha2_amd64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_amd64.apk' - }, { - name: 'tofu_1.6.0-alpha2_amd64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_amd64.deb' - }, { - name: 'tofu_1.6.0-alpha2_amd64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_amd64.rpm' - }, { - name: 'tofu_1.6.0-alpha2_arm.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_arm.apk' - }, { - name: 'tofu_1.6.0-alpha2_arm.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_arm.deb' - }, { - name: 'tofu_1.6.0-alpha2_arm.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_arm.rpm' - }, { - name: 'tofu_1.6.0-alpha2_arm64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_arm64.apk' - }, { - name: 'tofu_1.6.0-alpha2_arm64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_arm64.deb' - }, { - name: 'tofu_1.6.0-alpha2_arm64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_arm64.rpm' - }, { - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_darwin_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha2_darwin_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_darwin_arm64.zip' - }, { - name: 'tofu_1.6.0-alpha2_freebsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_freebsd_386.zip' - }, { - name: 'tofu_1.6.0-alpha2_freebsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_freebsd_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha2_freebsd_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_freebsd_arm.zip' - }, { - name: 'tofu_1.6.0-alpha2_linux_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_linux_386.zip' - }, { - name: 'tofu_1.6.0-alpha2_linux_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_linux_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha2_linux_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_linux_arm.zip' - }, { - name: 'tofu_1.6.0-alpha2_linux_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_linux_arm64.zip' - }, { - name: 'tofu_1.6.0-alpha2_openbsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_openbsd_386.zip' - }, { - name: 'tofu_1.6.0-alpha2_openbsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_openbsd_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha2_SHA256SUMS', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_SHA256SUMS' - }, { - name: 'tofu_1.6.0-alpha2_SHA256SUMS.pem', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_SHA256SUMS.pem' - }, { - name: 'tofu_1.6.0-alpha2_SHA256SUMS.sig', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_SHA256SUMS.sig' - }, { - name: 'tofu_1.6.0-alpha2_solaris_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_solaris_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha2_windows_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_windows_386.zip' - }, { - name: 'tofu_1.6.0-alpha2_windows_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha2/tofu_1.6.0-alpha2_windows_amd64.zip' - }] + id: 'v1.6.0-alpha2', + files: [ + 'tofu_1.6.0-alpha2_386.apk', + 'tofu_1.6.0-alpha2_386.deb', + 'tofu_1.6.0-alpha2_386.rpm', + 'tofu_1.6.0-alpha2_amd64.apk', + 'tofu_1.6.0-alpha2_amd64.deb', + 'tofu_1.6.0-alpha2_amd64.rpm', + 'tofu_1.6.0-alpha2_arm.apk', + 'tofu_1.6.0-alpha2_arm.deb', + 'tofu_1.6.0-alpha2_arm.rpm', + 'tofu_1.6.0-alpha2_arm64.apk', + 'tofu_1.6.0-alpha2_arm64.deb', + 'tofu_1.6.0-alpha2_arm64.rpm', + 'tofu_1.6.0-alpha2_darwin_arm64.zip', + 'tofu_1.6.0-alpha2_freebsd_386.zip', + 'tofu_1.6.0-alpha2_freebsd_amd64.zip', + 'tofu_1.6.0-alpha2_freebsd_arm.zip', + 'tofu_1.6.0-alpha2_linux_386.zip', + 'tofu_1.6.0-alpha2_linux_amd64.zip', + 'tofu_1.6.0-alpha2_linux_arm.zip', + 'tofu_1.6.0-alpha2_linux_arm64.zip', + 'tofu_1.6.0-alpha2_openbsd_386.zip', + 'tofu_1.6.0-alpha2_openbsd_amd64.zip', + 'tofu_1.6.0-alpha2_SHA256SUMS', + 'tofu_1.6.0-alpha2_SHA256SUMS.pem', + 'tofu_1.6.0-alpha2_SHA256SUMS.sig', + 'tofu_1.6.0-alpha2_solaris_amd64.zip', + 'tofu_1.6.0-alpha2_windows_386.zip', + 'tofu_1.6.0-alpha2_windows_amd64.zip' + ] }, { - tag_name: 'v1.6.0-alpha1', - assets: [{ - name: 'tofu_1.6.0-alpha1_386.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_386.apk' - }, { - name: 'tofu_1.6.0-alpha1_386.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_386.deb' - }, { - name: 'tofu_1.6.0-alpha1_386.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_386.rpm' - }, { - name: 'tofu_1.6.0-alpha1_amd64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_amd64.apk' - }, { - name: 'tofu_1.6.0-alpha1_amd64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_amd64.deb' - }, { - name: 'tofu_1.6.0-alpha1_amd64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_amd64.rpm' - }, { - name: 'tofu_1.6.0-alpha1_arm.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_arm.apk' - }, { - name: 'tofu_1.6.0-alpha1_arm.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_arm.deb' - }, { - name: 'tofu_1.6.0-alpha1_arm.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_arm.rpm' - }, { - name: 'tofu_1.6.0-alpha1_arm64.apk', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_arm64.apk' - }, { - name: 'tofu_1.6.0-alpha1_arm64.deb', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_arm64.deb' - }, { - name: 'tofu_1.6.0-alpha1_arm64.rpm', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_arm64.rpm' - }, { - name: 'tofu_1.6.0-alpha1_darwin_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_darwin_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha1_darwin_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_darwin_arm64.zip' - }, { - name: 'tofu_1.6.0-alpha1_freebsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_freebsd_386.zip' - }, { - name: 'tofu_1.6.0-alpha1_freebsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_freebsd_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha1_freebsd_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_freebsd_arm.zip' - }, { - name: 'tofu_1.6.0-alpha1_linux_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_linux_386.zip' - }, { - name: 'tofu_1.6.0-alpha1_linux_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_linux_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha1_linux_arm.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_linux_arm.zip' - }, { - name: 'tofu_1.6.0-alpha1_linux_arm64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_linux_arm64.zip' - }, { - name: 'tofu_1.6.0-alpha1_openbsd_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_openbsd_386.zip' - }, { - name: 'tofu_1.6.0-alpha1_openbsd_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_openbsd_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha1_SHA256SUMS', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_SHA256SUMS' - }, { - name: 'tofu_1.6.0-alpha1_SHA256SUMS.pem', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_SHA256SUMS.pem' - }, { - name: 'tofu_1.6.0-alpha1_SHA256SUMS.sig', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_SHA256SUMS.sig' - }, { - name: 'tofu_1.6.0-alpha1_solaris_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_solaris_amd64.zip' - }, { - name: 'tofu_1.6.0-alpha1_windows_386.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_windows_386.zip' - }, { - name: 'tofu_1.6.0-alpha1_windows_amd64.zip', - browser_download_url: 'https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_windows_amd64.zip' - }] + id: 'v1.6.0-alpha1', + files: [ + 'tofu_1.6.0-alpha1_386.apk', + 'tofu_1.6.0-alpha1_386.deb', + 'tofu_1.6.0-alpha1_386.rpm', + 'tofu_1.6.0-alpha1_amd64.apk', + 'tofu_1.6.0-alpha1_amd64.deb', + 'tofu_1.6.0-alpha1_amd64.rpm', + 'tofu_1.6.0-alpha1_arm.apk', + 'tofu_1.6.0-alpha1_arm.deb', + 'tofu_1.6.0-alpha1_arm.rpm', + 'tofu_1.6.0-alpha1_arm64.apk', + 'tofu_1.6.0-alpha1_arm64.deb', + 'tofu_1.6.0-alpha1_arm64.rpm', + 'tofu_1.6.0-alpha1_darwin_amd64.zip', + 'tofu_1.6.0-alpha1_darwin_arm64.zip', + 'tofu_1.6.0-alpha1_freebsd_386.zip', + 'tofu_1.6.0-alpha1_freebsd_amd64.zip', + 'tofu_1.6.0-alpha1_freebsd_arm.zip', + 'tofu_1.6.0-alpha1_linux_386.zip', + 'tofu_1.6.0-alpha1_linux_amd64.zip', + 'tofu_1.6.0-alpha1_linux_arm.zip', + 'tofu_1.6.0-alpha1_linux_arm64.zip', + 'tofu_1.6.0-alpha1_openbsd_386.zip', + 'tofu_1.6.0-alpha1_openbsd_amd64.zip', + 'tofu_1.6.0-alpha1_SHA256SUMS', + 'tofu_1.6.0-alpha1_SHA256SUMS.pem', + 'tofu_1.6.0-alpha1_SHA256SUMS.sig', + 'tofu_1.6.0-alpha1_solaris_amd64.zip', + 'tofu_1.6.0-alpha1_windows_386.zip', + 'tofu_1.6.0-alpha1_windows_amd64.zip' + ] }]; return mockReleasesMeta.map(el => new pkg.Release(el)); @@ -386,8 +157,12 @@ describe('getRelease', () => { [ ['foo', 'Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html', mockFetchReleases], ['2.0', 'No matching version found', mockFetchReleases], - ['latest', 'No tofu releases found, please contact OpenTofu', async () => { return null; }], - ['latest', 'No tofu releases found, please contact OpenTofu', async () => { return []; }] + ['latest', 'No tofu releases found, please contact OpenTofu', async () => { + return null; + }], + ['latest', 'No tofu releases found, please contact OpenTofu', async () => { + return []; + }] ] )('unhappy path: getRelease(\'%s\') -> throw Error(\'%s\')', async (input, wantErrorMessage, mockFetchReleasesFn) => { try { diff --git a/package-lock.json b/package-lock.json index 8a4b9fe..bf19f05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1777,12 +1777,13 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2023,10 +2024,11 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -2999,10 +3001,11 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -3661,6 +3664,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -4714,12 +4718,13 @@ "dev": true }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, + "license": "MIT", "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -5907,6 +5912,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, + "license": "MIT", "dependencies": { "is-number": "^7.0.0" },