├── .github └── workflows │ ├── test_action.yml │ └── update_tag.yml ├── LICENSE ├── README.md └── action.yml /.github/workflows/test_action.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | test: 14 | name: ${{ matrix.os }} 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | os: 19 | - windows-latest # Windows Server 2022 (windows-2022) 20 | - windows-2019 # Windows Server 2019 21 | - ubuntu-22.04 # Ubuntu 22.04 22 | - ubuntu-latest # Ubuntu 20.04 (ubuntu-20.04) 23 | - ubuntu-18.04 # Ubuntu 18.04 24 | - macos-12 # macOS Monterey 12 25 | - macos-latest # macOS Big Sur 11 (macos-11) 26 | - macos-10.15 # macOS Catalina 10.15 27 | # https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#choosing-github-hosted-runners 28 | steps: 29 | - uses: actions/checkout@v2 30 | - uses: ./ 31 | with: 32 | brew: hello yq 33 | brew-cask: MacVim 34 | apt: rolldice bcal 35 | choco: graphviz less 36 | -------------------------------------------------------------------------------- /.github/workflows/update_tag.yml: -------------------------------------------------------------------------------- 1 | name: Update Major Version Tag 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | jobs: 9 | update-majorver: 10 | name: Update Major Version Tag 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: nowactions/update-majorver@v1 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2022 OpenAstronomy Developers 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## install-package 2 | 3 | [![.github/workflows/main.yml](https://github.com/ConorMacBride/install-package/actions/workflows/test_action.yml/badge.svg)](https://github.com/ConorMacBride/install-package/actions/workflows/test_action.yml) 4 | 5 | A GitHub action to install packages with apt on Linux, brew and brew cask on macOS and choco on Windows. 6 | 7 | ## Inputs 8 | - `brew: [package ...]` (macOS) 9 | - `brew-cask: [package ...]` (macOS) 10 | - `apt: [package ...]` (Linux) 11 | - `choco: [package ...]` (Windows) 12 | 13 | All inputs are accepted on all platforms, however, each input's string of packages are only installed if the platform is supported. 14 | 15 | ## Example 16 | 17 | ```yaml 18 | jobs: 19 | test_code: 20 | name: Test code 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: ConorMacBride/install-package@v1 24 | with: 25 | brew: hello yq 26 | brew-cask: MacVim 27 | apt: rolldice bcal 28 | choco: graphviz less 29 | ``` 30 | 31 | As the runner OS is Linux, only `rolldice` and `bcal` are installed. 32 | 33 | ## Notes 34 | 35 | This action is intended to be used within an action, workflow or reusable workflow where the `runner.os` is variable, such as setting the runner from a matrix: 36 | 37 | ```yaml 38 | jobs: 39 | test_code: 40 | name: Test code 41 | runs-on: ${{ matrix.os }} 42 | strategy: 43 | matrix: ... 44 | steps: 45 | - ... 46 | - uses: ConorMacBride/install-package@v1 47 | with: 48 | brew: openjpeg 49 | apt: libopenjp2-7 50 | - ... 51 | ``` 52 | 53 | This can simplify your configurations, as this action takes care of choosing which package manager to use. 54 | It also allows for variations in the package names between package managers. 55 | 56 | However, if the `runner.os` always stays the same in your workflow, or you are only configuring one package manager, it may be better to call the commands yourself rather than adding a new dependency to your workflow. 57 | For example, 58 | 59 | ```yaml 60 | jobs: 61 | test_code: 62 | name: Test code 63 | runs-on: ubuntu-latest 64 | steps: 65 | # ... this step: 66 | - uses: ConorMacBride/install-package@v1 67 | with: 68 | apt: libopenjp2-7 69 | # ... should probably be replaced with this step: 70 | - runs: sudo apt update && sudo apt install -y libopenjp2-7 71 | ``` 72 | 73 | If you want to use the latest available version of this action instead 74 | of hard-coding a specific version, you can replace 75 | ``ConorMacBride/install-package@v1`` by ``ConorMacBride/install-package@main``. 76 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Install Package' 2 | description: 'Install system packages from brew, brew cask, apt and choco.' 3 | branding: 4 | icon: package 5 | color: blue 6 | inputs: 7 | brew: 8 | description: Packages to install with brew on macOS 9 | required: false 10 | default: '' 11 | brew-cask: 12 | description: Packages to install with brew cask on macOS 13 | required: false 14 | default: '' 15 | apt: 16 | description: Packages to install with apt on Linux 17 | required: false 18 | default: '' 19 | # yum: 20 | # description: Packages to install with yum inside Docker on Linux 21 | # required: false 22 | # default: '' 23 | choco: 24 | description: Packages to install with choco on Windows 25 | required: false 26 | default: '' 27 | runs: 28 | using: "composite" 29 | steps: 30 | 31 | - name: Install brew packages 32 | if: runner.os == 'macOS' && inputs.brew != '' 33 | run: | 34 | brew update 35 | echo "${{ inputs.brew }}" | xargs -n 1 brew install 36 | shell: sh 37 | 38 | - name: Install brew cask packages 39 | if: runner.os == 'macOS' && inputs.brew-cask != '' 40 | run: | 41 | brew update 42 | echo "${{ inputs.brew-cask }}" | xargs -n 1 brew install --cask 43 | shell: sh 44 | 45 | - name: Install apt packages 46 | if: runner.os == 'Linux' && inputs.apt != '' 47 | run: | 48 | sudo apt update 49 | sudo apt install -y ${{ inputs.apt }} 50 | shell: sh 51 | 52 | - name: Install choco packages 53 | if: runner.os == 'Windows' && inputs.choco != '' 54 | run: choco install -y ${{ inputs.choco }} 55 | shell: sh 56 | --------------------------------------------------------------------------------