Skip to content

Commit 142d0c3

Browse files
committed
{action.yml,.github}: add support for macOS
Add support for running the action on macOS-based GitHub runners. Updates TODO
1 parent c29cd81 commit 142d0c3

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

.github/workflows/tailscale.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- main
7+
- 'mpminardi/mac-support'
88
pull_request:
99
branches:
1010
- '*'
@@ -13,7 +13,7 @@ jobs:
1313
build:
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest]
16+
os: [ubuntu-latest, windows-latest, macos-latest]
1717
runs-on: ${{ matrix.os }}
1818
steps:
1919
- name: Check out code

action.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ runs:
5252
using: 'composite'
5353
steps:
5454
- name: Check Runner OS
55-
if: ${{ runner.os != 'Linux' && runner.os != 'Windows' }}
55+
if: ${{ runner.os != 'Linux' && runner.os != 'Windows' && runner.os != 'macOS'}}
5656
shell: bash
5757
run: |
58-
echo "::error title=⛔ error hint::Support Linux or Windows Only"
58+
echo "::error title=⛔ error hint::Support Linux, Windows, and macOS Only"
5959
exit 1
6060
- name: Check Auth Info Empty
6161
if: ${{ inputs.authkey == '' && (inputs['oauth-secret'] == '' || inputs.tags == '') }}
@@ -144,6 +144,28 @@ runs:
144144
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
145145
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
146146
Remove-Item tailscale.msi -Force;
147+
- name: Checkout Tailscale repo - macOS
148+
if: ${{ runner.os == 'macOS' }}
149+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
150+
with:
151+
repository: tailscale/tailscale
152+
path: ${{ github.workspace }}/tailscale
153+
# Use main for cron, or the supplied provider branch if manually triggered.
154+
ref: ${{ github.event_name == 'schedule' && 'main' || inputs.providerBranch }}
155+
- name: Build Tailscale binaries - macOS
156+
if: ${{ runner.os == 'macOS' }}
157+
shell: bash
158+
run: |
159+
cd tailscale
160+
export TS_USE_TOOLCHAIN=1
161+
./build_dist.sh ./cmd/tailscale
162+
./build_dist.sh ./cmd/tailscaled
163+
sudo mv tailscale tailscaled /usr/bin
164+
- name: Install timeout - macOS
165+
if: ${{ runner.os == 'macOS' }}
166+
shell: bash
167+
run:
168+
brew install coreutils # for 'timeout'
147169
- name: Start Tailscale Daemon - Linux
148170
if: ${{ runner.os == 'Linux' }}
149171
shell: bash
@@ -171,17 +193,22 @@ runs:
171193
TIMEOUT: ${{ inputs.timeout }}
172194
run: |
173195
if [ -z "${HOSTNAME}" ]; then
174-
if [ "${{ runner.os }}" == "Linux" ]; then
175-
HOSTNAME="github-$(cat /etc/hostname)"
176-
elif [ "${{ runner.os }}" == "Windows" ]; then
196+
if [ "${{ runner.os }}" == "Windows" ]; then
177197
HOSTNAME="github-$COMPUTERNAME"
198+
else
199+
HOSTNAME="github-$(hostname)"
178200
fi
179201
fi
180202
if [ -n "${{ inputs['oauth-secret'] }}" ]; then
181203
TAILSCALE_AUTHKEY="${{ inputs['oauth-secret'] }}?preauthorized=true&ephemeral=true"
182204
TAGS_ARG="--advertise-tags=${{ inputs.tags }}"
183205
fi
184-
if [ "${{ runner.os }}" == "Linux" ]; then
206+
if [ "${{ runner.os }}" != "Windows" ]; then
185207
MAYBE_SUDO="sudo -E"
186208
fi
187209
timeout --verbose --kill-after=1s ${TIMEOUT} ${MAYBE_SUDO} tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}
210+
- name: Set DNS servers - macOS
211+
if: ${{ runner.os == 'macOS' }}
212+
shell: bash
213+
run:
214+
networksetup -setdnsservers "Ethernet" 100.100.100.100

0 commit comments

Comments
 (0)