NOTE: This is a fork of the original melusina-org/setup-macports repository.
This GitHub Action configure and installs MacPorts. It supports the selection and deselection of port variants, the use of supplementary port definitions sources and the installation of additional ports.
Create a workflow file in the.github/workflows directory of your
working copy. This workflow file should use a MacOS runner such as
macos-latest and use the branch v1 of this action.
Once the action has been executed, the port command from MacPorts is
available and can be used to install ports, create packages, and any
other task it supports. The ports installation is owned by the runner,
thus no root access is required to install ports.
The ports tree is synchronised as part of the action, so there is no
need to run port sync or port selfupdate afterwards. The default
ports tree source, rsync.macports.org, is a fixed alias for a single
mirror that is occasionally unreachable or stalled, so:
rsync_optionsinmacports.confis configured with a transfer timeout before anything is synchronised, including theport selfupdaterun by the postflight script of the MacPorts package. A mirror that stalls once connected fails promptly instead of hanging. A mirror that never accepts the connection still takes as long as the TCP connection timeout to fail, about 75 seconds.- The synchronisation is retried a few times with an increasing delay, and the last attempt runs with debug output so that a persistent failure leaves a usable diagnostic in the workflow log.
- When
sourcesis not set, later attempts use other official MacPorts mirrors (bos.us.rsync.macports.org, thenfra.de.rsync.macports.org) for the same signedrelease/tarballs/ports.tar, so MacPorts still verifies its signature.sources.confis left naming the mirror that succeeded, as the ports tree is stored per source. Whensourcesis set, it is used as is for every attempt.
This only covers the synchronisation done by the action. A later
port sync in your workflow still uses the configured timeout, but is
not retried.
An example workflow and an example parameter file are available below. See the GitHub Help Documentation for Creating a workflow file to get started with GitHub workflows.
parameters— Pathname to a configuration file for the SETUP-MACPORTS action. When no pathname is provided, the configuration is expected to be found under.github/parameters/setup-macports.yaml. It is however no error when this file is not present.
The configuration file is in YAML and has the following format:
version: '2.12.5'— The MacPorts version to install. On the prefix/opt/localthis selects the MacPorts package, but does not pin MacPorts base: the postflight script of the package runsport selfupdate, which upgrades base to the newest release. The installed version is therefore this version or newer. On any other prefix base is built from source at this version and is not upgraded. The ports tree is always synced to the newest one, which may require a recent base.prefix: '/opt/local'— The installation prefix to install MacPorts to. On/opt/localthe MacPorts package is installed; on any other prefix base is built from source. The default is/opt/localand only needs to be changed when preparing self-install packages for instance.variants.select: []— The list of selected variants in the global variants configuration. See Also variants.conf(5).variants.deselect: []— The list of deselected variants in the global variants configuration. See Also: variants.conf(5).sources: ['rsync://rsync.macports.org/macports/release/tarballs/ports.tar']— The list of source locations for port definitions. The first entry of the list is marked with default. See Also: sources.conf(5)ports: []— The list of additional ports to install. Each term of the list is a dictionart with the mandatory 'name' holding the name of the port to install, optional key 'select' for the list of selected variants for this port, and the optional 'key' deselect for the list of deselected variants for this port.
package— The URL of the MacPorts package used for the installation on the prefix/opt/local. On any other prefix MacPorts is built from source and this package is not used.prefix— The installation prefix to install MacPorts to.version— The requested MacPorts version, as described under Parameter file. On the prefix/opt/localthe installed version can be newer.installed-version— The MacPorts version installed, as reported byport version.
This workflow reads its parameters from the default location
.github/parameters/setup-macports.yaml, with the content shown under
Example parameters.
name: 'Run Testsuite'
on:
- workflow_dispatch
- push
jobs:
install-macports-on-macos-15:
runs-on: macos-15
name: 'Install MacPorts 2.12.5 on MacOS 15'
steps:
- uses: actions/checkout@v3
- uses: paranext/setup-macports@v1
id: 'macports'
- name: 'Validate installed MacPorts version'
# The installed version is the requested one or newer.
shell: bash
run: |
installed=$(port version | sed -n -e 's/^Version: //p')
oldest=$(printf '%s\n%s\n' "${installed}" '2.12.5' | sort -V | head -1)
test "${oldest}" = '2.12.5'
- name: 'Validate transmitted MacPorts prefix'
run: >-
test "${{ steps.macports.outputs.prefix }}" = '/opt/local'
- name: 'Validate transmitted MacPorts version'
run: >-
test "${{ steps.macports.outputs.version }}" = '2.12.5'
install-macports-on-macos-26:
runs-on: macos-26
name: 'Install MacPorts 2.12.5 on MacOS 26'
steps:
- uses: actions/checkout@v3
- uses: paranext/setup-macports@v1
- run: port versionversion: '2.12.5'
prefix: '/opt/local'
variants:
select:
- aqua
- metal
deselect: x11
ports:
- name: db48
deselect: [ java ]
select: [ tcl, universal ]
- name: gmp
select: native
The scripts and documentation in this project are released under the MIT License.
Copyright Information:
- Original code: Copyright © 2022–2023 Michaël Le Barbier
- Subsequent changes: Copyright © 2025 SIL Global and United Bible Societies
This fork removes all Lisp dependencies and related development tooling that were present in the original repository:
- Removed all Common Lisp code and ASDF system definitions
- Removed Lisp-based linting functionality
- Updated build scripts to work without Lisp dependencies
- All core MacPorts installation functionality remains intact