Skip to content

Commit ec6a7e4

Browse files
committed
Correctly set the executable name
1 parent 5789f03 commit ec6a7e4

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ in the [Jsonnet] language.
1111
## Getting started
1212

1313
When specifying `tanka-version` the `v` prefix can be omitted, additionally,
14-
the patch number is not required if it is equal to zero.
14+
the patch number is not required if it is equal to zero. The versions `v0.16.0`,
15+
`0.16.0`, `v0.16`, and `0.16` are all valid and all refer to the same semantic
16+
version of Tanka.
1517

1618
### Inputs
1719

18-
| Name | Default | Description |
19-
| --------------- | :--------: | ---------------------- |
20-
| `tanka-version` | `"0.16.0"` | Grafana Tanka version. |
20+
| Name | Default | Description |
21+
| --------------- | :---------: | ---------------------- |
22+
| `tanka-version` | `"v0.16.0"` | Grafana Tanka version. |
2123

2224
### Example usage
2325

24-
The following workflow uses the action to apply a production configuration.
26+
The following example workflow uses the setup-tanka action to automatically
27+
apply resources to a production environment.
2528

2629
```yaml
2730
name: Deploy

__tests__/setup-tanka.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ describe('GitHub Actions × Grafana Tanka', () => {
7979
['win32', 'amd64', 'tk-windows-amd64.exe'],
8080
['win32', 'x64', 'tk-windows-amd64.exe'],
8181
])(
82-
'installs the correct binary for %s/%s',
83-
async (platform, arch, binary) => {
82+
'installs the correct executable for %s/%s',
83+
async (platform, arch, exe) => {
8484
os.platform = platform;
8585
os.arch = arch;
8686

8787
downloadToolSpy.mockImplementation(() => '/temp');
8888
await tanka.install('0.16.0');
8989

9090
expect(downloadToolSpy).toHaveBeenCalledWith(
91-
`https://github.com/grafana/tanka/releases/download/v0.16.0/${binary}`,
91+
`https://github.com/grafana/tanka/releases/download/v0.16.0/${exe}`,
9292
undefined
9393
);
9494
}

dist/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ const os = __importStar(__nccwpck_require__(87));
128128
function install(version) {
129129
return __awaiter(this, void 0, void 0, function* () {
130130
const semanticVersion = formatVersion(version);
131-
const executableName = getExecutableName();
132-
const tkDownloadUrl = `https://github.com/grafana/tanka/releases/download/${semanticVersion}/${executableName}`;
131+
const exeDownloadName = getExeDownloadName();
132+
const tkDownloadUrl = `https://github.com/grafana/tanka/releases/download/${semanticVersion}/${exeDownloadName}`;
133133
core.info(`Download Grafana Tanka ${semanticVersion} from ${tkDownloadUrl}`);
134134
const tkDownload = yield tc.downloadTool(tkDownloadUrl, undefined);
135135
const tkDownloadPath = path_1.default.basename(tkDownload);
136-
const tk = path_1.default.join(tkDownloadPath, 'tk');
136+
const tk = path_1.default.join(tkDownloadPath, getExeName());
137137
core.debug(`Move ${tkDownload} to ${tk}`);
138138
yield io.mv(tkDownload, tk);
139139
core.debug(`Make ${tk} executable`);
@@ -143,7 +143,13 @@ function install(version) {
143143
});
144144
}
145145
exports.install = install;
146-
function getExecutableName() {
146+
function getExeName() {
147+
if (os.platform().toString() === 'win32') {
148+
return 'tk.exe';
149+
}
150+
return 'tk';
151+
}
152+
function getExeDownloadName() {
147153
let arch = os.arch();
148154
let ext = '';
149155
let platform = os.platform().toString();

src/tanka.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ import * as os from 'os';
2222

2323
export async function install(version: string): Promise<void> {
2424
const semanticVersion = formatVersion(version);
25-
const executableName = getExecutableName();
26-
const tkDownloadUrl = `https://github.com/grafana/tanka/releases/download/${semanticVersion}/${executableName}`;
25+
const exeDownloadName = getExeDownloadName();
26+
const tkDownloadUrl = `https://github.com/grafana/tanka/releases/download/${semanticVersion}/${exeDownloadName}`;
2727

2828
core.info(`Download Grafana Tanka ${semanticVersion} from ${tkDownloadUrl}`);
2929
const tkDownload = await tc.downloadTool(tkDownloadUrl, undefined);
3030

3131
const tkDownloadPath = path.basename(tkDownload);
32-
const tk = path.join(tkDownloadPath, 'tk');
32+
const tk = path.join(tkDownloadPath, getExeName());
3333

3434
core.debug(`Move ${tkDownload} to ${tk}`);
3535
await io.mv(tkDownload, tk);
@@ -41,7 +41,15 @@ export async function install(version: string): Promise<void> {
4141
core.addPath(tkDownloadPath);
4242
}
4343

44-
function getExecutableName(): string {
44+
function getExeName(): string {
45+
if (os.platform().toString() === 'win32') {
46+
return 'tk.exe';
47+
}
48+
49+
return 'tk';
50+
}
51+
52+
function getExeDownloadName(): string {
4553
let arch = os.arch();
4654
let ext = '';
4755
let platform = os.platform().toString();

0 commit comments

Comments
 (0)