Skip to content

Commit ab6e990

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 ab6e990

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
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: 36 additions & 9 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,8 +144,30 @@ 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: Start Tailscale Daemon - Linux
148-
if: ${{ runner.os == 'Linux' }}
147+
- name: Checkout Tailscale repo - macOS
148+
# TODO: checkout proper tag
149+
if: ${{ runner.os == 'macOS' }}
150+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
151+
with:
152+
repository: tailscale/tailscale
153+
path: ${{ github.workspace }}/tailscale
154+
ref: v1.76.6
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/local/bin
164+
- name: Install timeout - macOS
165+
if: ${{ runner.os == 'macOS' }}
166+
shell: bash
167+
run:
168+
brew install coreutils # for 'timeout'
169+
- name: Start Tailscale Daemon - non-Windows
170+
if: ${{ runner.os != 'Windows' }}
149171
shell: bash
150172
env:
151173
ADDITIONAL_DAEMON_ARGS: ${{ inputs.tailscaled-args }}
@@ -157,7 +179,7 @@ runs:
157179
STATE_ARGS="--statedir=${STATEDIR}"
158180
mkdir -p "$STATEDIR"
159181
fi
160-
sudo -E tailscaled ${STATE_ARGS} ${ADDITIONAL_DAEMON_ARGS} 2>~/tailscaled.log &
182+
sudo -E tailscaled ${STATE_ARGS} ${ADDITIONAL_DAEMON_ARGS} 2>&1 | tee ~/tailscaled.log &
161183
# And check that tailscaled came up. The CLI will block for a bit waiting
162184
# for it. And --json will make it exit with status 0 even if we're logged
163185
# out (as we will be). Without --json it returns an error if we're not up.
@@ -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)