Skip to content

Commit eb43def

Browse files
committed
{action.yml,.github}: add support for windows
WIP on adding windows support
1 parent 2b49897 commit eb43def

File tree

2 files changed

+68
-8
lines changed

2 files changed

+68
-8
lines changed

.github/workflows/tailscale.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- main
7+
- 'mpminardi/windows-support'
88
pull_request:
99
branches:
1010
- '*'
1111

1212
jobs:
1313
build:
14-
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest]
17+
runs-on: ${{ matrix.os }}
1518
steps:
1619
- name: Check out code
1720
uses: actions/checkout@v2
@@ -24,5 +27,6 @@ jobs:
2427
tags: tag:ci
2528

2629
- name: check for hello.ts.net in netmap
30+
shell: bash
2731
run:
2832
tailscale status | grep -q hello

action.yml

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ runs:
5252
using: 'composite'
5353
steps:
5454
- name: Check Runner OS
55-
if: ${{ runner.os != 'Linux' }}
55+
if: ${{ runner.os != 'Linux' && runner.os != 'Windows' }}
5656
shell: bash
5757
run: |
58-
echo "::error title=⛔ error hint::Support Linux Only"
58+
echo "::error title=⛔ error hint::Support Linux or Windows Only"
5959
exit 1
6060
- name: Check Auth Info Empty
6161
if: ${{ inputs.authkey == '' && (inputs['oauth-secret'] == '' || inputs.tags == '') }}
6262
shell: bash
6363
run: |
6464
echo "::error title=⛔ error hint::OAuth identity empty, Maybe you need to populate it in the Secrets for your workflow, see more in https://docs.github.com/en/actions/security-guides/encrypted-secrets and https://tailscale.com/s/oauth-clients"
6565
exit 1
66-
- name: Download Tailscale
66+
- name: Download Tailscale - Linux
67+
if: ${{ runner.os == 'Linux' }}
6768
shell: bash
68-
id: download
6969
env:
7070
VERSION: ${{ inputs.version }}
7171
SHA256SUM: ${{ inputs.sha256sum }}
@@ -103,7 +103,49 @@ runs:
103103
rm tailscale.tgz
104104
TSPATH=/tmp/tailscale_${VERSION}_${TS_ARCH}
105105
sudo mv "${TSPATH}/tailscale" "${TSPATH}/tailscaled" /usr/bin
106-
- name: Start Tailscale Daemon
106+
- name: Download Tailscale - Windows
107+
if: ${{ runner.os == 'Windows' }}
108+
shell: bash
109+
env:
110+
VERSION: ${{ inputs.version }}
111+
SHA256SUM: ${{ inputs.sha256sum }}
112+
run: |
113+
if [ "$VERSION" = "latest" ]; then
114+
VERSION=$(curl -s "https://pkgs.tailscale.com/stable/?mode=json" | jq -r .Version)
115+
echo "Latest Tailscale version: $VERSION"
116+
fi
117+
if [ X64 = "ARM64" ]; then
118+
TS_ARCH="arm64"
119+
elif [ X64 = "X86" ]; then
120+
TS_ARCH="x86"
121+
elif [ X64 = "X64" ]; then
122+
TS_ARCH="amd64"
123+
else
124+
TS_ARCH="amd64"
125+
fi
126+
MINOR=$(echo "$VERSION" | awk -F '.' {'print $2'})
127+
if [ $((MINOR % 2)) -eq 0 ]; then
128+
URL="https://pkgs.tailscale.com/stable/tailscale-setup-${VERSION}-${TS_ARCH}.msi"
129+
else
130+
URL="https://pkgs.tailscale.com/unstable/tailscale-setup-${VERSION}-${TS_ARCH}.msi"
131+
fi
132+
echo "Downloading $URL"
133+
curl -H user-agent:tailscale-github-action -L "$URL" -o tailscale.msi --max-time 300 --fail
134+
if ! [[ "$SHA256SUM" ]] ; then
135+
SHA256SUM="$(curl -H user-agent:tailscale-github-action -L "${URL}.sha256" --fail)"
136+
fi
137+
echo "Expected sha256: $SHA256SUM"
138+
echo "Actual sha256: $(sha256sum tailscale.msi)"
139+
echo "$SHA256SUM tailscale.msi" | sha256sum -c
140+
- name: Install Tailscale - Windows
141+
if: ${{ runner.os == 'Windows' }}
142+
shell: pwsh
143+
run: |
144+
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
145+
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
146+
Remove-Item tailscale.msi -Force;
147+
- name: Start Tailscale Daemon - Linux
148+
if: ${{ runner.os == 'Linux' }}
107149
shell: bash
108150
env:
109151
ADDITIONAL_DAEMON_ARGS: ${{ inputs.tailscaled-args }}
@@ -120,7 +162,8 @@ runs:
120162
# for it. And --json will make it exit with status 0 even if we're logged
121163
# out (as we will be). Without --json it returns an error if we're not up.
122164
sudo -E tailscale status --json >/dev/null
123-
- name: Connect to Tailscale
165+
- name: Connect to Tailscale - Linux
166+
if: ${{ runner.os == 'Linux' }}
124167
shell: bash
125168
env:
126169
ADDITIONAL_ARGS: ${{ inputs.args }}
@@ -137,3 +180,16 @@ runs:
137180
TAGS_ARG="--advertise-tags=${{ inputs.tags }}"
138181
fi
139182
timeout --verbose --kill-after=1s ${TIMEOUT} sudo -E tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}
183+
- name: Connect to Tailscale - Windows
184+
if: ${{ runner.os == 'Windows' }}
185+
shell: pwsh
186+
run: |
187+
$hostname = "${{ inputs.hostname }}"
188+
if (-not "${HOSTNAME}" ) {
189+
$hostname ="github-" + $env:computername
190+
}
191+
if ("${{ inputs['oauth-secret'] }}") {
192+
$TAILSCALE_AUTHKEY="${{ inputs['oauth-secret'] }}?preauthorized=true&ephemeral=true"
193+
$TAGS_ARG="--advertise-tags=${{ inputs.tags }}"
194+
}
195+
tailscale up $TAGS_ARG --authkey=$TAILSCALE_AUTHKEY --hostname=$HOSTNAME --accept-routes ${{ inputs.args }}

0 commit comments

Comments
 (0)