Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{action.yml,.github}: add support for windows #160

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/tailscale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v2
Expand All @@ -24,5 +27,6 @@ jobs:
tags: tag:ci

- name: check for hello.ts.net in netmap
shell: bash
run:
tailscale status | grep -q hello
66 changes: 55 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ runs:
using: 'composite'
steps:
- name: Check Runner OS
if: ${{ runner.os != 'Linux' }}
if: ${{ runner.os != 'Linux' && runner.os != 'Windows' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Linux Only"
echo "::error title=⛔ error hint::Support Linux or Windows Only"
exit 1
- name: Check Auth Info Empty
if: ${{ inputs.authkey == '' && (inputs['oauth-secret'] == '' || inputs.tags == '') }}
shell: bash
run: |
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"
exit 1
- name: Download Tailscale
- name: Download Tailscale - Linux
if: ${{ runner.os == 'Linux' }}
shell: bash
id: download
env:
VERSION: ${{ inputs.version }}
SHA256SUM: ${{ inputs.sha256sum }}
run: |
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -s "https://pkgs.tailscale.com/stable/?mode=json" | jq -r .Version)
VERSION=$(curl -H user-agent:tailscale-github-action -s "https://pkgs.tailscale.com/stable/?mode=json" | jq -r .Version)
echo "Latest Tailscale version: $VERSION"
fi
if [ ${{ runner.arch }} = "ARM64" ]; then
Expand All @@ -80,8 +80,6 @@ runs:
TS_ARCH="arm"
elif [ ${{ runner.arch }} = "X86" ]; then
TS_ARCH="386"
elif [ ${{ runner.arch }} = "X64" ]; then
TS_ARCH="amd64"
else
TS_ARCH="amd64"
fi
Expand All @@ -103,7 +101,47 @@ runs:
rm tailscale.tgz
TSPATH=/tmp/tailscale_${VERSION}_${TS_ARCH}
sudo mv "${TSPATH}/tailscale" "${TSPATH}/tailscaled" /usr/bin
- name: Start Tailscale Daemon
- name: Download Tailscale - Windows
if: ${{ runner.os == 'Windows' }}
shell: bash
env:
VERSION: ${{ inputs.version }}
SHA256SUM: ${{ inputs.sha256sum }}
run: |
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -H user-agent:tailscale-github-action -s "https://pkgs.tailscale.com/stable/?mode=json" | jq -r .Version)
echo "Latest Tailscale version: $VERSION"
fi
if [ ${{ runner.arch }} = "ARM64" ]; then
TS_ARCH="arm64"
elif [ ${{ runner.arch }} = "X86" ]; then
TS_ARCH="x86"
else
TS_ARCH="amd64"
fi
MINOR=$(echo "$VERSION" | awk -F '.' {'print $2'})
if [ $((MINOR % 2)) -eq 0 ]; then
URL="https://pkgs.tailscale.com/stable/tailscale-setup-${VERSION}-${TS_ARCH}.msi"
else
URL="https://pkgs.tailscale.com/unstable/tailscale-setup-${VERSION}-${TS_ARCH}.msi"
fi
echo "Downloading $URL"
curl -H user-agent:tailscale-github-action -L "$URL" -o tailscale.msi --max-time 300 --fail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the custom user-agent here!

if ! [[ "$SHA256SUM" ]] ; then
SHA256SUM="$(curl -H user-agent:tailscale-github-action -L "${URL}.sha256" --fail)"
fi
echo "Expected sha256: $SHA256SUM"
echo "Actual sha256: $(sha256sum tailscale.msi)"
echo "$SHA256SUM tailscale.msi" | sha256sum -c
- name: Install Tailscale - Windows
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
Remove-Item tailscale.msi -Force;
- name: Start Tailscale Daemon - Linux
if: ${{ runner.os == 'Linux' }}
shell: bash
env:
ADDITIONAL_DAEMON_ARGS: ${{ inputs.tailscaled-args }}
Expand All @@ -127,13 +165,19 @@ runs:
HOSTNAME: ${{ inputs.hostname }}
TAILSCALE_AUTHKEY: ${{ inputs.authkey }}
TIMEOUT: ${{ inputs.timeout }}
TS_EXPERIMENT_OAUTH_AUTHKEY: true
run: |
if [ -z "${HOSTNAME}" ]; then
HOSTNAME="github-$(cat /etc/hostname)"
if [ "${{ runner.os }}" == "Linux" ]; then
HOSTNAME="github-$(cat /etc/hostname)"
elif [ "${{ runner.os }}" == "Windows" ]; then
HOSTNAME="github-$COMPUTERNAME"
fi
fi
if [ -n "${{ inputs['oauth-secret'] }}" ]; then
TAILSCALE_AUTHKEY="${{ inputs['oauth-secret'] }}?preauthorized=true&ephemeral=true"
TAGS_ARG="--advertise-tags=${{ inputs.tags }}"
fi
timeout --verbose --kill-after=1s ${TIMEOUT} sudo -E tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}
if [ "${{ runner.os }}" == "Linux" ]; then
MAYBE_SUDO="sudo -E"
fi
timeout --verbose --kill-after=1s ${TIMEOUT} ${MAYBE_SUDO} tailscale up ${TAGS_ARG} --authkey=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --accept-routes ${ADDITIONAL_ARGS}