Skip to content

Add platform info utilities to @actions/core - #1551

Merged
luketomlinson merged 5 commits into
actions:mainfrom
akv-platform:add-platform-info-utilities
Nov 14, 2023
Merged

luketomlinson merged 5 commits into
actions:mainfrom
akv-platform:add-platform-info-utilities

Conversation

@nikolai-laevskii

Copy link
Copy Markdown
Contributor

Adds shorthands for getting information about platform action is running on:

import { platform } from '@actions/core'

/* same as os.platform() */
platform.platform // 'win32' | 'darwin' | 'linux' | 'freebsd' | 'openbsd' | 'android' | 'cygwin' | 'sunos'

/* same as os.arch() */
platform.arch // 'x64' | 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x'

/* common shorthands for platform-specific logic */
platform.isWindows // true
platform.isMacOS // false
platform.isLinux // false

/* run platform-specific script to get more details about the exact platform, works on Windows, MacOS and Linux */
const {
  name, // Microsoft Windows 11 Enterprise
  version, // 10.0.22621
} = await platform.getDetails()

@nikolai-laevskii
nikolai-laevskii requested a review from a team as a code owner October 9, 2023 03:54
@nikolai-laevskii nikolai-laevskii changed the title Add platform info utilities Add platform info utilities to @actions/core Oct 9, 2023
@dhensby

dhensby commented Oct 8, 2024

Copy link
Copy Markdown

I just want to say that I really appreciate this bit of functionality - thanks @nikolai-laevskii - it's allowed me to remove some custom code from my own action 🎉

Derrick-MUGISHA pushed a commit to Derrick-MUGISHA/toolkit that referenced this pull request Oct 12, 2026
* Introduce platform utilities into @actions/core

* Add tests for the platform helper

* Update README.md

* Update README.md with more details
Derrick-MUGISHA pushed a commit to Derrick-MUGISHA/toolkit that referenced this pull request Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants