1. Introduction
2. Installing MacPorts
2.1. Install Xcode
2.2. Install MacPorts
2.3. Upgrade MacPorts
2.4. Uninstall MacPorts
2.5. MacPorts and the Shell
3. Using MacPorts
3.1. The port Command
3.2. Port Variants
3.3. Common Tasks
3.4. Port Binaries
4. Portfile Development
4.1. Portfile Introduction
4.2. Creating a Portfile
4.3. Example Portfiles
4.4. Port Variants
4.5. Patch Files
4.6. Local Portfile Repositories
4.7. Portfile Best Practices
4.8. MacPorts' buildbot
5. Portfile Reference
5.1. Global Keywords
5.2. Global Variables
5.3. Port Phases
5.4. Dependencies
5.5. Variants
5.6. Tcl Extensions & Useful Tcl Commands
5.7. StartupItems
5.8. Livecheck / Distcheck
5.9. PortGroups
5.10. PortGroup Introduction
5.11. PortGroup github
5.12. PortGroup gnustep
5.13. PortGroup golang
5.14. PortGroup haskell
5.15. PortGroup java
5.16. PortGroup perl5
5.17. PortGroup python
5.18. PortGroup ruby
5.19. PortGroup xcode
6. MacPorts Internals
6.1. File Hierarchy
6.2. Configuration Files
6.3. Port Images
6.4. APIs and Libs
6.5. The MacPorts Registry
6.6. Tests
7. MacPorts Project
7.1. Using Trac for Tickets
7.2. Using Git and GitHub
7.3. Contributing to MacPorts
7.4. Port Update Policies
7.5. Updating Documentation
7.6. MacPorts Membership
7.7. The PortMgr Team
8. MacPorts Guide Glossary
Glossary

5.11. PortGroup github

The github portgroup allows for efficient porting of software hosted on GitHub.

5.11.1. Description

This portgroup greatly simplifies the porting of software hosted on GitHub. Provided a GitHub repository author follows common GitHub practices, a port can be almost fully configured simply by declaring the repository coordinates. The github portgroup is indeed capable of configuring, amongst other things:

  • The port +name+.
  • The port +version+.
  • The distfiles (if the project uses GitHub releases).
  • The livecheck parameters.

5.11.2. Setting up the GitHub repository coordinates

The main port configuration is triggered by the usage of the github.setup keyword:

PortGroup           github 1.0
github.setup        author project version [tag_prefix]

By default, the port name will be set to the GitHub project name (+project+) and version will be set to the GitHub project +version+. The port name can be overridden by using the name keyword.

The tag_prefix is optional, and it’s used to specify a prefix to use when constructing the tag name. If, for example, the project uses tags such as +v1.0.0+, then the tag_prefix should be set to +v+, as in the following example:

github.setup        author project version v

5.11.3. Choosing a distfile strategy

GitHub, and as a consequence the github portgroup, offers multiple mechanisms to get a distfile:

  • Distfile from a git commit or tag.
  • Distfile from a GitHub release.
  • Distfile from a GitHub download.
  • Distfile from Github auto-generated archive downloads

The default behaviour of the portgroup is using GitHub automatically generated distfile from a git commit or tag. However, the best practice should be using a GitHub release.

5.11.4. Distfile from tag or commit

The default behaviour of the github portgroup is leveraging GitHub’s ability to create a distfile from a git tag or commit. In this case, the distname is irrelevant and should not be set.

If the project’s developers do not tag their releases, they should be encouraged to do so. Until they do, or in the case in which an untagged development version has to be used, port maintainers have the possibility of specifying a git commit hash and manually set the version field. If the project does not assign version numbers the port maintainer has to define one. Such versions typically format the date of the chosen commit using the YYYYMMDD pattern. If, for example, the port maintainer decides to use a changeset with the hash +0ff25277c3842598d919cd3c73d60768+, committed on April 1, 2014, then the following would be used:

github.setup        someone someproject 0ff25277c3842598d919cd3c73d60768
version             20140401

5.11.5. Distfile from a GitHub release

The github portgroup allows maintainers to easily configure the distfiles when the project uses GitHub releases. A release is the best distfile candidate, and project maintainers should be encouraged to use them. To enable this feature, the following keyword must be used:

github.tarball_from releases

By default, the github portgroup sets distname to:

distname            ${github.project}-${github.version}

However, GitHub does not enforce any rule for release distfiles, so port maintainers may need to override the distname as they would do for other ports.

5.11.6. Distfile from a GitHub download

Older projects use the discontinued downloads service. New GitHub downloads can no longer be created, but old ones are still available.

If the project doesn’t have GitHub releases but does have GitHub downloads, they can be used using the following keyword:

github.tarball_from downloads

Since GitHub doesn’t enforce any naming rules for downloads, the portgroup can only provide a sensible default value for +distname+, which can be overridden if necessary.

5.11.7. Distfile from GitHub archive downloads

Further still, many Github projects have automatically-generated archive URLs that can be used for downloading distfiles. This can be enabled via archive as follows:

github.tarball_from archive

5.11.8. Using repositories with git submodules

If the project uses git submodules, some projects' tag- or commit-based distfiles will not contain all the necessary files. Once again, the best distfile candidate (if available) is a distfile from GitHub releases, as described in the previous sections. However, in the case a project doesn’t provide any other alternative, a project using submodules can be successfully retrieved by fetching the sources using git and then using a post-fetch to initialize the submodules:

fetch.type          git

post-fetch {
    system -W ${worksrcpath} "git submodule update --init"
}