mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-28 19:14:22 +01:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ac6ac05f7 | ||
|
|
f3476b1637 | ||
|
|
d00c6817f1 | ||
|
|
da3271e0a2 | ||
|
|
24b9f144af | ||
|
|
05c2a037e9 | ||
|
|
b06654f7ba | ||
|
|
6cdd07fc43 | ||
|
|
5f01fa71eb | ||
|
|
8767493626 | ||
|
|
abd9f2b70f | ||
|
|
595213afdb |
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
name: Retag
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[1-2].[0-9]+.[0-9]+*'
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: |
|
||||||
|
set -o pipefail
|
||||||
|
git tag --force "$(grep '^v[1-2]\.[0-9]\+\.[0-9]\+\(.*\)\?$' <<< ${GITHUB_REF#refs/*/} | sed 's/^v\([1-2]\)\..*/v\1/')"
|
||||||
|
git push --tag --force
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ defaults:
|
|||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tofu-versions:
|
tofu-versions:
|
||||||
name: 'OpenTofu Versions'
|
name: 'OpenTofu Versions'
|
||||||
@@ -24,6 +27,8 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup OpenTofu - ${{ matrix['tofu-versions'] }}
|
- name: Setup OpenTofu - ${{ matrix['tofu-versions'] }}
|
||||||
|
env:
|
||||||
|
ACTIONS_STEP_DEBUG: $ACTIONS_STEP_DEBUG
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
tofu_version: ${{ matrix['tofu-versions'] }}
|
tofu_version: ${{ matrix['tofu-versions'] }}
|
||||||
@@ -47,6 +52,8 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup OpenTofu
|
- name: Setup OpenTofu
|
||||||
|
env:
|
||||||
|
ACTIONS_STEP_DEBUG: $ACTIONS_STEP_DEBUG
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}
|
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}
|
||||||
@@ -70,6 +77,8 @@ jobs:
|
|||||||
run: tofu fmt -check -list=true -no-color
|
run: tofu fmt -check -list=true -no-color
|
||||||
tofu-run-local:
|
tofu-run-local:
|
||||||
name: 'OpenTofu Run Local'
|
name: 'OpenTofu Run Local'
|
||||||
|
env:
|
||||||
|
ACTIONS_STEP_DEBUG: $ACTIONS_STEP_DEBUG
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -77,6 +86,7 @@ jobs:
|
|||||||
tofu-wrapper: [true, false]
|
tofu-wrapper: [true, false]
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
|
shell: bash
|
||||||
working-directory: ./.github/workflows/data/local
|
working-directory: ./.github/workflows/data/local
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -108,6 +118,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
env:
|
env:
|
||||||
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||||
|
ACTIONS_STEP_DEBUG: $ACTIONS_STEP_DEBUG
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -137,6 +148,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
env:
|
env:
|
||||||
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||||
|
ACTIONS_STEP_DEBUG: $ACTIONS_STEP_DEBUG
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -161,6 +173,8 @@ jobs:
|
|||||||
|
|
||||||
tofu-credentials-none:
|
tofu-credentials-none:
|
||||||
name: 'OpenTofu No Credentials'
|
name: 'OpenTofu No Credentials'
|
||||||
|
env:
|
||||||
|
ACTIONS_STEP_DEBUG: $ACTIONS_STEP_DEBUG
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -181,4 +195,3 @@ jobs:
|
|||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
run: |
|
run: |
|
||||||
[[ -f ${HOME}/.tofurc ]] || exit 0
|
[[ -f ${HOME}/.tofurc ]] || exit 0
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
## Unreleased
|
|
||||||
|
|
||||||
Initial release. It provides feature parity with the [setup-terraform](https://github.com/hashicorp/setup-terraform) action.
|
|
||||||
@@ -22,23 +22,23 @@ The default configuration installs the latest version of OpenTofu CLI and instal
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
```
|
```
|
||||||
|
|
||||||
A specific version of OpenTofu CLI can be installed:
|
A specific version of OpenTofu CLI can be installed:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
with:
|
with:
|
||||||
tofu_version: 1.6.0-alpha1
|
tofu_version: 1.6.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Credentials for Terraform Cloud ([app.terraform.io](https://app.terraform.io/)) can be configured:
|
Credentials for Terraform Cloud ([app.terraform.io](https://app.terraform.io/)) can be configured:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
with:
|
with:
|
||||||
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
|
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
|
||||||
```
|
```
|
||||||
@@ -47,7 +47,7 @@ Credentials for Terraform Enterprise (TFE) can be configured:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
with:
|
with:
|
||||||
cli_config_credentials_hostname: 'tofu.example.com'
|
cli_config_credentials_hostname: 'tofu.example.com'
|
||||||
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
|
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
|
||||||
@@ -57,7 +57,7 @@ The wrapper script installation can be skipped by setting the `tofu_wrapper` var
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
with:
|
with:
|
||||||
tofu_wrapper: false
|
tofu_wrapper: false
|
||||||
```
|
```
|
||||||
@@ -66,7 +66,7 @@ Subsequent steps can access outputs when the wrapper script is installed:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
|
|
||||||
- run: tofu init
|
- run: tofu init
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ permissions:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
|
|
||||||
- name: OpenTofu fmt
|
- name: OpenTofu fmt
|
||||||
id: fmt
|
id: fmt
|
||||||
@@ -162,7 +162,7 @@ permissions:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: opentofu/setup-opentofu
|
- uses: opentofu/setup-opentofu@v1
|
||||||
|
|
||||||
- name: OpenTofu fmt
|
- name: OpenTofu fmt
|
||||||
id: fmt
|
id: fmt
|
||||||
@@ -257,6 +257,7 @@ The action supports the following inputs:
|
|||||||
- `tofu_wrapper` - (optional) Whether to install a wrapper to wrap subsequent calls of
|
- `tofu_wrapper` - (optional) Whether to install a wrapper to wrap subsequent calls of
|
||||||
the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs
|
the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs
|
||||||
named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.
|
named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.
|
||||||
|
- `github_token` - (optional) Override the GitHub token read from the environment variable. Defaults to the value of the `GITHUB_TOKEN` environment variable unless running on Forgejo or Gitea.
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -17,6 +17,14 @@ inputs:
|
|||||||
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
|
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
|
github_token:
|
||||||
|
description: 'API token for GitHub to increase the rate limit. Defaults to the GITHUB_TOKEN environment variable unless running on Forgejo/Gitea.'
|
||||||
|
default: ''
|
||||||
|
required: false
|
||||||
|
step_debug_logging:
|
||||||
|
description: 'This increases job log verbosity during and after execution when set to `true`. Defaults to `false`'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
stdout:
|
stdout:
|
||||||
description: 'The STDOUT stream of the call to the `tofu` binary.'
|
description: 'The STDOUT stream of the call to the `tofu` binary.'
|
||||||
@@ -29,8 +37,8 @@ outputs:
|
|||||||
value: '126'
|
value: '126'
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: 'terminal'
|
icon: 'box'
|
||||||
color: 'purple'
|
color: 'yellow'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
Vendored
+22
-9
@@ -33,18 +33,24 @@ class Release {
|
|||||||
*
|
*
|
||||||
* @return {Array<Release>} Releases.
|
* @return {Array<Release>} Releases.
|
||||||
*/
|
*/
|
||||||
async function fetchReleases () {
|
async function fetchReleases (githubToken) {
|
||||||
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
Accept: 'application/vnd.github+json',
|
||||||
|
'X-GitHub-Api-Version': '2022-11-28'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (githubToken) {
|
||||||
|
headers.Authorization = `Bearer ${githubToken}`;
|
||||||
|
}
|
||||||
|
|
||||||
const resp = await fetch(url, {
|
const resp = await fetch(url, {
|
||||||
headers: {
|
headers
|
||||||
Accept: 'application/vnd.github+json',
|
|
||||||
'X-GitHub-Api-Version': '2022-11-28'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
throw new Error('failed fetching releases');
|
throw new Error('failed fetching releases (' + resp.status + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
const releasesMeta = await resp.json();
|
const releasesMeta = await resp.json();
|
||||||
@@ -66,10 +72,11 @@ async function findLatestVersionInRange (versions, range) {
|
|||||||
* Fetches the release given the version.
|
* Fetches the release given the version.
|
||||||
*
|
*
|
||||||
* @param {string} version: Release version.
|
* @param {string} version: Release version.
|
||||||
|
* @param {string} githubToken: GitHub token to use for working around rate limits.
|
||||||
* @param {function} fetchReleasesFn: Optional function to fetch releases.
|
* @param {function} fetchReleasesFn: Optional function to fetch releases.
|
||||||
* @return {Release} Release.
|
* @return {Release} Release.
|
||||||
*/
|
*/
|
||||||
async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
async function getRelease (version, githubToken, fetchReleasesFn = fetchReleases) {
|
||||||
const latestVersionLabel = 'latest';
|
const latestVersionLabel = 'latest';
|
||||||
|
|
||||||
const versionsRange = semver.validRange(version, { prerelease: true, loose: true });
|
const versionsRange = semver.validRange(version, { prerelease: true, loose: true });
|
||||||
@@ -77,7 +84,7 @@ async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
|||||||
throw new Error('Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html');
|
throw new Error('Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
const releases = await fetchReleasesFn();
|
const releases = await fetchReleasesFn(githubToken);
|
||||||
|
|
||||||
if (releases === null || releases.length === 0) {
|
if (releases === null || releases.length === 0) {
|
||||||
throw new Error('No tofu releases found, please contact OpenTofu');
|
throw new Error('No tofu releases found, please contact OpenTofu');
|
||||||
@@ -245,13 +252,19 @@ async function run () {
|
|||||||
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
||||||
const credentialsToken = core.getInput('cli_config_credentials_token');
|
const credentialsToken = core.getInput('cli_config_credentials_token');
|
||||||
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
||||||
|
let githubToken = core.getInput('github_token');
|
||||||
|
if (githubToken === '' && !(process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS)) {
|
||||||
|
// Only default to the environment variable when running in GitHub Actions. Don't do this for other CI systems
|
||||||
|
// that may set the GITHUB_TOKEN environment variable.
|
||||||
|
githubToken = process.env.GITHUB_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
// Gather OS details
|
// Gather OS details
|
||||||
const osPlatform = os.platform();
|
const osPlatform = os.platform();
|
||||||
const osArch = os.arch();
|
const osArch = os.arch();
|
||||||
|
|
||||||
core.debug(`Finding releases for OpenTofu version ${version}`);
|
core.debug(`Finding releases for OpenTofu version ${version}`);
|
||||||
const release = await releases.getRelease(version);
|
const release = await releases.getRelease(version, githubToken);
|
||||||
const platform = mapOS(osPlatform);
|
const platform = mapOS(osPlatform);
|
||||||
const arch = mapArch(osArch);
|
const arch = mapArch(osArch);
|
||||||
const build = release.getBuild(platform, arch);
|
const build = release.getBuild(platform, arch);
|
||||||
|
|||||||
+15
-8
@@ -27,18 +27,24 @@ class Release {
|
|||||||
*
|
*
|
||||||
* @return {Array<Release>} Releases.
|
* @return {Array<Release>} Releases.
|
||||||
*/
|
*/
|
||||||
async function fetchReleases () {
|
async function fetchReleases (githubToken) {
|
||||||
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
Accept: 'application/vnd.github+json',
|
||||||
|
'X-GitHub-Api-Version': '2022-11-28'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (githubToken) {
|
||||||
|
headers.Authorization = `Bearer ${githubToken}`;
|
||||||
|
}
|
||||||
|
|
||||||
const resp = await fetch(url, {
|
const resp = await fetch(url, {
|
||||||
headers: {
|
headers
|
||||||
Accept: 'application/vnd.github+json',
|
|
||||||
'X-GitHub-Api-Version': '2022-11-28'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
throw new Error('failed fetching releases');
|
throw new Error('failed fetching releases (' + resp.status + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
const releasesMeta = await resp.json();
|
const releasesMeta = await resp.json();
|
||||||
@@ -60,10 +66,11 @@ async function findLatestVersionInRange (versions, range) {
|
|||||||
* Fetches the release given the version.
|
* Fetches the release given the version.
|
||||||
*
|
*
|
||||||
* @param {string} version: Release version.
|
* @param {string} version: Release version.
|
||||||
|
* @param {string} githubToken: GitHub token to use for working around rate limits.
|
||||||
* @param {function} fetchReleasesFn: Optional function to fetch releases.
|
* @param {function} fetchReleasesFn: Optional function to fetch releases.
|
||||||
* @return {Release} Release.
|
* @return {Release} Release.
|
||||||
*/
|
*/
|
||||||
async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
async function getRelease (version, githubToken, fetchReleasesFn = fetchReleases) {
|
||||||
const latestVersionLabel = 'latest';
|
const latestVersionLabel = 'latest';
|
||||||
|
|
||||||
const versionsRange = semver.validRange(version, { prerelease: true, loose: true });
|
const versionsRange = semver.validRange(version, { prerelease: true, loose: true });
|
||||||
@@ -71,7 +78,7 @@ async function getRelease (version, fetchReleasesFn = fetchReleases) {
|
|||||||
throw new Error('Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html');
|
throw new Error('Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
const releases = await fetchReleasesFn();
|
const releases = await fetchReleasesFn(githubToken);
|
||||||
|
|
||||||
if (releases === null || releases.length === 0) {
|
if (releases === null || releases.length === 0) {
|
||||||
throw new Error('No tofu releases found, please contact OpenTofu');
|
throw new Error('No tofu releases found, please contact OpenTofu');
|
||||||
|
|||||||
+10
-1
@@ -132,13 +132,19 @@ async function run () {
|
|||||||
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
||||||
const credentialsToken = core.getInput('cli_config_credentials_token');
|
const credentialsToken = core.getInput('cli_config_credentials_token');
|
||||||
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
||||||
|
let githubToken = core.getInput('github_token');
|
||||||
|
if (githubToken === '' && !(process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS)) {
|
||||||
|
// Only default to the environment variable when running in GitHub Actions. Don't do this for other CI systems
|
||||||
|
// that may set the GITHUB_TOKEN environment variable.
|
||||||
|
githubToken = process.env.GITHUB_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
// Gather OS details
|
// Gather OS details
|
||||||
const osPlatform = os.platform();
|
const osPlatform = os.platform();
|
||||||
const osArch = os.arch();
|
const osArch = os.arch();
|
||||||
|
|
||||||
core.debug(`Finding releases for OpenTofu version ${version}`);
|
core.debug(`Finding releases for OpenTofu version ${version}`);
|
||||||
const release = await releases.getRelease(version);
|
const release = await releases.getRelease(version, githubToken);
|
||||||
const platform = mapOS(osPlatform);
|
const platform = mapOS(osPlatform);
|
||||||
const arch = mapArch(osArch);
|
const arch = mapArch(osArch);
|
||||||
const build = release.getBuild(platform, arch);
|
const build = release.getBuild(platform, arch);
|
||||||
@@ -149,6 +155,9 @@ async function run () {
|
|||||||
// Download requested version
|
// Download requested version
|
||||||
const pathToCLI = await downloadAndExtractCLI(build.url);
|
const pathToCLI = await downloadAndExtractCLI(build.url);
|
||||||
|
|
||||||
|
const stepDebugLogging = core.getInput('step_debug_logging');
|
||||||
|
core.exportVariable('ACTIONS_STEP_DEBUG', stepDebugLogging);
|
||||||
|
|
||||||
// Install our wrapper
|
// Install our wrapper
|
||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
await installWrapper(pathToCLI);
|
await installWrapper(pathToCLI);
|
||||||
|
|||||||
@@ -197,20 +197,20 @@ describe('getRelease', () => {
|
|||||||
]
|
]
|
||||||
)('happy path: getRelease(\'%s\') -> \'%s\'', async (input, wantVersion) => {
|
)('happy path: getRelease(\'%s\') -> \'%s\'', async (input, wantVersion) => {
|
||||||
const want = mockFetchReleases().find(el => el.version === wantVersion);
|
const want = mockFetchReleases().find(el => el.version === wantVersion);
|
||||||
const gotRelease = await pkg.getRelease(input, mockFetchReleases);
|
const gotRelease = await pkg.getRelease(input, '', mockFetchReleases);
|
||||||
expect(gotRelease).toEqual(want);
|
expect(gotRelease).toEqual(want);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(
|
it.each(
|
||||||
[
|
[
|
||||||
['foo', 'Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html', undefined],
|
['foo', 'Input version cannot be used, see semver: https://semver.org/spec/v2.0.0.html', mockFetchReleases],
|
||||||
['2.0', 'No matching version found', undefined],
|
['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 null; }],
|
||||||
['latest', 'No tofu releases found, please contact OpenTofu', async () => { return []; }]
|
['latest', 'No tofu releases found, please contact OpenTofu', async () => { return []; }]
|
||||||
]
|
]
|
||||||
)('unhappy path: getRelease(\'%s\') -> throw Error(\'%s\')', async (input, wantErrorMessage, mockFetchReleasesFn) => {
|
)('unhappy path: getRelease(\'%s\') -> throw Error(\'%s\')', async (input, wantErrorMessage, mockFetchReleasesFn) => {
|
||||||
try {
|
try {
|
||||||
await pkg.getRelease(input, mockFetchReleasesFn);
|
await pkg.getRelease(input, '', mockFetchReleasesFn);
|
||||||
expect(true).toBe(false);
|
expect(true).toBe(false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toBe(wantErrorMessage);
|
expect(e.message).toBe(wantErrorMessage);
|
||||||
|
|||||||
Generated
+12
-49
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-opentofu",
|
"name": "setup-opentofu",
|
||||||
"version": "0.0.1",
|
"version": "1.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "setup-opentofu",
|
"name": "setup-opentofu",
|
||||||
"version": "0.0.1",
|
"version": "1.0.1",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.10.1",
|
"@actions/core": "1.10.1",
|
||||||
@@ -16,10 +16,9 @@
|
|||||||
"semver": "7.5.4"
|
"semver": "7.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "0.38.0",
|
"@vercel/ncc": "0.38.1",
|
||||||
"husky": "8.0.3",
|
"husky": "9.0.11",
|
||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
"nock": "13.3.3",
|
|
||||||
"semistandard": "17.0.0"
|
"semistandard": "17.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1397,9 +1396,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@vercel/ncc": {
|
"node_modules/@vercel/ncc": {
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.0.tgz",
|
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz",
|
||||||
"integrity": "sha512-B4YKZMm/EqMptKSFyAq4q2SlgJe+VCmEH6Y8gf/E1pTlWbsUJpuH1ymik2Ex3aYO5mCWwV1kaSYHSQOT8+4vHA==",
|
"integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"ncc": "dist/ncc/cli.js"
|
"ncc": "dist/ncc/cli.js"
|
||||||
@@ -3362,15 +3361,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/husky": {
|
"node_modules/husky": {
|
||||||
"version": "8.0.3",
|
"version": "9.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz",
|
||||||
"integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
|
"integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"husky": "lib/bin.js"
|
"husky": "bin.mjs"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/typicode"
|
"url": "https://github.com/sponsors/typicode"
|
||||||
@@ -4525,12 +4524,6 @@
|
|||||||
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
|
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/json-stringify-safe": {
|
|
||||||
"version": "5.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
|
||||||
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/json5": {
|
"node_modules/json5": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||||
@@ -4663,12 +4656,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
|
||||||
"version": "4.17.21",
|
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/lodash.merge": {
|
"node_modules/lodash.merge": {
|
||||||
"version": "4.6.2",
|
"version": "4.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
|
||||||
@@ -4781,21 +4768,6 @@
|
|||||||
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
|
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/nock": {
|
|
||||||
"version": "13.3.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/nock/-/nock-13.3.3.tgz",
|
|
||||||
"integrity": "sha512-z+KUlILy9SK/RjpeXDiDUEAq4T94ADPHE3qaRkf66mpEhzc/ytOMm3Bwdrbq6k1tMWkbdujiKim3G2tfQARuJw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^4.1.0",
|
|
||||||
"json-stringify-safe": "^5.0.1",
|
|
||||||
"lodash": "^4.17.21",
|
|
||||||
"propagate": "^2.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.13"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/node-int64": {
|
"node_modules/node-int64": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||||
@@ -5289,15 +5261,6 @@
|
|||||||
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
|
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/propagate": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/punycode": {
|
"node_modules/punycode": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz",
|
||||||
|
|||||||
+3
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-opentofu",
|
"name": "setup-opentofu",
|
||||||
"version": "0.0.1",
|
"version": "1.0.1",
|
||||||
"description": "Setup OpenTofu CLI for GitHub Actions",
|
"description": "Setup OpenTofu CLI for GitHub Actions",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"publisher": "OpenTofu",
|
"publisher": "OpenTofu",
|
||||||
@@ -26,10 +26,9 @@
|
|||||||
"semver": "7.5.4"
|
"semver": "7.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "0.38.0",
|
"@vercel/ncc": "0.38.1",
|
||||||
"husky": "8.0.3",
|
"husky": "9.0.11",
|
||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
"nock": "13.3.3",
|
|
||||||
"semistandard": "17.0.0"
|
"semistandard": "17.0.0"
|
||||||
},
|
},
|
||||||
"semistandard": {
|
"semistandard": {
|
||||||
|
|||||||
Reference in new issue
Block a user