Gitlab-Runner unter Catalina mittels Homebrew

635 Wörter 3 Minuten Lesezeit

Für ein Projekt mussten die Binaries nicht nur für Debian (glibc) und Alpine (musl) gebaut werden sondern auch für macOS Catalina. Mittels Homebrew war der Runner im Nu online und in der Gitlab Pipeline integriert.

Installieren von Homebrew

user@catalina ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/bin
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/share
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/sbin/chown vbox /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/mkdir -p /Users/vbox/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/vbox/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown vbox /Users/vbox/Library/Caches/Homebrew
==> Searching online for the Command Line Tools
==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> Installing Command Line Tools for Xcode-12.2
==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ for\ Xcode-12.2
Software Update Tool


Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
==> Downloading and installing Homebrew...
remote: Enumerating objects: 65, done.
remote: Counting objects: 100% (65/65), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 161194 (delta 6), reused 59 (delta 6), pack-reused 161129
Receiving objects: 100% (161194/161194), 41.32 MiB | 2.26 MiB/s, done.
Resolving deltas: 100% (119466/119466), done.
From https://github.com/Homebrew/brew
 * [new branch]      dependabot/bundler/Library/Homebrew/sorbet-0.5.6105 -> origin/dependabot/bundler/Library/Homebrew/sorbet-0.5.6105
 * [new branch]      master              -> origin/master
 * [new branch]      sorbet-files-update -> origin/sorbet-files-update
 * [new tag]             0.1                 -> 0.1
...
 * [new tag]             2.5.9               -> 2.5.9
Updating files: 100% (2244/2244), done.
HEAD is now at 918fbcc26 Merge pull request #9247 from reitermarkus/deprecate-cask-commands
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 139, done.
remote: Counting objects: 100% (139/139), done.
remote: Compressing objects: 100% (127/127), done.
remote: Total 845046 (delta 94), reused 24 (delta 12), pack-reused 844907
Receiving objects: 100% (845046/845046), 336.68 MiB | 12.44 MiB/s, done.
Resolving deltas: 100% (569662/569662), done.
Updating files: 100% (5619/5619), done.
Tapped 2 commands and 5356 formulae (5,644 files, 369.4MB).
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh

brew analytics off

Root-Zertifikat installieren

openssl x509 -outform der -in rootCAcert.pem -out rootCAcert.der
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCAcert.der 
openssl x509 -outform der -in CAcert.pem -out CAcert.der 
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain CAcert.der  

Gitlab-Runner 13.6.0 installieren

brew install gitlab-runner
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/gitlab-runner-13.6.0.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/b93031424b9b694f0c7092f84cef651a2e19a142de9a06d2d07c9268eb9
######################################################################## 100.0%
==> Pouring gitlab-runner-13.6.0.catalina.bottle.tar.gz
==> Caveats
To have launchd start gitlab-runner now and restart at login:
  brew services start gitlab-runner
Or, if you don't want/need a background service you can just run:
  gitlab-runner start
==> Summary
🍺  /usr/local/Cellar/gitlab-runner/13.6.0: 4 files, 48.9MB

Gitlab-Runner starten

/usr/local/bin/gitlab-runner

Gitlab Pipeline erweitern

.build-make-template:
    stage: build
    rules:
        - exists:
            - Makefile
    needs: []
    artifacts:
        when: on_success
        name: "${CI_PROJECT_PATH_SLUG}-${CI_PIPELINE_ID}-${CI_JOB_NAME}-${CI_COMMIT_SHA}"
        expire_in: 1 week
        untracked: true
        exclude:
            - "*.o"
    script:
        - make
build-macos:
    extends: 
        - .build-make-template
    tags:
        - macos