Skip to content

Commit 4605be6

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 5dddea1 commit 4605be6

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-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: 31 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 == '') }}
@@ -140,8 +140,30 @@ runs:
140140
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
141141
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
142142
Remove-Item tailscale.msi -Force;
143-
- name: Start Tailscale Daemon - Linux
144-
if: ${{ runner.os == 'Linux' }}
143+
- name: Checkout Tailscale repo - macOS
144+
# TODO: checkout proper tag
145+
if: ${{ runner.os == 'macOS' }}
146+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
147+
with:
148+
repository: tailscale/tailscale
149+
path: ${{ github.workspace }}/tailscale
150+
ref: v1.76.6
151+
- name: Build Tailscale binaries - macOS
152+
if: ${{ runner.os == 'macOS' }}
153+
shell: bash
154+
run: |
155+
cd tailscale
156+
export TS_USE_TOOLCHAIN=1
157+
./build_dist.sh ./cmd/tailscale
158+
./build_dist.sh ./cmd/tailscaled
159+
sudo mv tailscale tailscaled /usr/local/bin
160+
- name: Install timeout - macOS
161+
if: ${{ runner.os == 'macOS' }}
162+
shell: bash
163+
run:
164+
brew install coreutils # for 'timeout'
165+
- name: Start Tailscale Daemon - non-Windows
166+
if: ${{ runner.os != 'Windows' }}
145167
shell: bash
146168
env:
147169
ADDITIONAL_DAEMON_ARGS: ${{ inputs.tailscaled-args }}
@@ -153,7 +175,7 @@ runs:
153175
STATE_ARGS="--statedir=${STATEDIR}"
154176
mkdir -p "$STATEDIR"
155177
fi
156-
sudo -E tailscaled ${STATE_ARGS} ${ADDITIONAL_DAEMON_ARGS} 2>~/tailscaled.log &
178+
sudo -E tailscaled ${STATE_ARGS} ${ADDITIONAL_DAEMON_ARGS} 2>&1 | tee ~/tailscaled.log &
157179
# And check that tailscaled came up. The CLI will block for a bit waiting
158180
# for it. And --json will make it exit with status 0 even if we're logged
159181
# out (as we will be). Without --json it returns an error if we're not up.
@@ -167,17 +189,17 @@ runs:
167189
TIMEOUT: ${{ inputs.timeout }}
168190
run: |
169191
if [ -z "${HOSTNAME}" ]; then
170-
if [ "${{ runner.os }}" == "Linux" ]; then
171-
HOSTNAME="github-$(cat /etc/hostname)"
172-
elif [ "${{ runner.os }}" == "Windows" ]; then
192+
if [ "${{ runner.os }}" == "Windows" ]; then
173193
HOSTNAME="github-$COMPUTERNAME"
194+
else
195+
HOSTNAME="github-$(hostname)"
174196
fi
175197
fi
176198
if [ -n "${{ inputs['oauth-secret'] }}" ]; then
177199
TAILSCALE_AUTHKEY="${{ inputs['oauth-secret'] }}?preauthorized=true&ephemeral=true"
178200
TAGS_ARG="--advertise-tags=${{ inputs.tags }}"
179201
fi
180-
if [ "${{ runner.os }}" == "Linux" ]; then
202+
if [ "${{ runner.os }}" != "Windows" ]; then
181203
MAYBE_SUDO="sudo -E"
182204
fi
183205
timeout --verbose --kill-after=1s ${TIMEOUT} ${MAYBE_SUDO} tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}

0 commit comments

Comments
 (0)