Skip to content

Instantly share code, notes, and snippets.

@RLovelett
Last active March 18, 2020 22:01
Show Gist options
  • Save RLovelett/1890ed3b9e5524e57e7aa4a66408cac6 to your computer and use it in GitHub Desktop.
Save RLovelett/1890ed3b9e5524e57e7aa4a66408cac6 to your computer and use it in GitHub Desktop.
Systemd Unit and Timer to Build Swift Everyday

Swift Toolchain Build

These systemd unit and timer configurations will get an up-to-date copy of Swift and build the toolchain every day at 2:00 AM local time.

Prerequisites

In order for these configurations to work without modification it is assumed that all of the development dependencies are already installed and that the Swift repository is cloned in $HOME/Source/swift-source/swift.

Install

$ mkdir -p $HOME/.config/systemd/user
$ cd $HOME/.config/systemd/user
$ wget https://gist.github.com/RLovelett/1890ed3b9e5524e57e7aa4a66408cac6/raw/update-and-build-swift-master.service
$ wget https://gist.github.com/RLovelett/1890ed3b9e5524e57e7aa4a66408cac6/raw/swift-daily-build.timer
$ systemctl --user daemon-reload
$ systemctl --user start swift-daily-build.timer
$ systemctl --user list-timers --all

Uninstall

$ systemctl --user disable swift-daily-build.timer
$ systemctl --user disable update-and-build-swift-master.service
$ systemctl --user reset-failed
[Unit]
Description=Run Update and Build Swift master Daily
[Timer]
OnCalendar=*-*-* 2:00:00
Persistent=true
Unit=update-and-build-swift-master.service
[Install]
WantedBy=default.target
[Unit]
Description=Update and Build Swift master
[Service]
Type=oneshot
WorkingDirectory=%h/Source/swift-source
ExecStartPre=%h/Source/swift-source/swift/utils/update-checkout --reset-to-remote --scheme master
ExecStart=%h/Source/swift-source/swift/utils/build-toolchain me.lovelett.daily
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment