Skip to content

Commit

Permalink
[FEAT] - Add support for CPU architecture (#1)
Browse files Browse the repository at this point in the history
* [FEAT] - Add support for CPU architecture

* Fix enum

* Add more architectures
  • Loading branch information
tutte authored May 23, 2024
1 parent 3793017 commit db0f701
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions src/argo-cd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ import * as path from 'path';
import * as process from 'process';

const PLATFORM = process.platform;
const CPU_ARCH = os.arch();
const EXE_NAME = PLATFORM === 'win32' ? 'argocd.exe' : 'argocd';
const ASSET_DEST = path.join(os.homedir(), EXE_NAME);

enum Executable {
aix,
android,
cygwin,
freebsd,
netbsd,
openbsd,
sunos,
darwin = 'argocd-darwin-amd64',
linux = 'argocd-linux-amd64',
win32 = 'argocd-windows-amd64.exe',
enum CPUArchitectures {
x64 = 'amd64',
arm64 = 'arm64',
ppc64 = 'ppc64le',
s390x = 's390x',
}

export default class ArgoCD {
Expand All @@ -49,7 +44,11 @@ export default class ArgoCD {
// If hitting GitHub API rate limit, add `GITHUB_TOKEN` to raise limit
const octoConfig = process.env.GITHUB_TOKEN ? {authStrategy: createActionAuth} : {};
const octokit = new Octokit(octoConfig);
const executable = Executable[PLATFORM];
let executable = `argocd-${PLATFORM}-${CPUArchitectures[CPU_ARCH]}`;

if (PLATFORM === 'win32') {
executable = 'argocd-windows-amd64.exe';
}

try {
const releases = await octokit.repos.getReleaseByTag({
Expand Down

0 comments on commit db0f701

Please sign in to comment.