> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# hubci/sphere

This orb elevates Circle to the next dimension. It pre-bakes environment
variables that assist in OS detection and GitHub tasks.

This can be useful in order to know which binaries to run, where certain
files may be located in the filesystem, whether or not using `sudo` is
needed, or to find the base branch in a GitHub PR.

This orb is especially helpful as a utility in creating your own
cross-platform orbs.

Bash is a requirement. This orb supports the Docker, machine, and macOS
executors. This includes Linux, amd64 and arm64 as well as macOS amd65. See
repository for full documentation.


## Commands

### init

Run OS detection and initialize environment variables.

## Examples

### detect-os

Here's how you would use the Sphere Orb.

```yaml
version: '2.1'
orbs:
  detect: hubci/sphere@0.2.0
jobs:
  build:
    docker:
      - image: cimg/base:2023.01
    steps:
      - detect/init
      - run: echo "The current operating system is ${OSD_ID}."
      - run:
          command: |
            case $OSD_FAMILY in
              linux)
                osVersion=$(grep -e "^DISTRIB_RELEASE=" /etc/lsb-release | cut -c17-)
                if [ $OSD_ID == "alpine" ]; then
                  # Here is where you would install an Alpine specific binary.
                  # This might be the case because Alpine doesn't have the
                  # same libs as most Linux distros.
                else
                  # Here is where you would install generic Linux binaries.
                fi
                ;;
              darwin)
                osVersion=$(sw_vers -productVersion)
                # Here is where you would install a macOS binary.
                ;;
              *)
                echo "Unsupported Operating System."
                exit 1
                ;;
            esac
          name: Install the binary for X
workflows: null
```