@@ -48,6 +48,10 @@ inputs:
4848 description : ' Timeout for `tailscale up`'
4949 required : false
5050 default : ' 2m'
51+ use-cache :
52+ description : ' Whether to cache the Tailscale binaries (Linux/macOS) or installer (Windows)'
53+ required : false
54+ default : ' false'
5155runs :
5256 using : ' composite'
5357 steps :
6367 run : |
6468 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"
6569 exit 1
70+
6671 - name : Set Resolved Version
6772 shell : bash
6873 run : |
7479 fi
7580 echo "RESOLVED_VERSION=$RESOLVED_VERSION" >> $GITHUB_ENV
7681 echo "Resolved Tailscale version: $RESOLVED_VERSION"
77- - name : Download Tailscale - Linux
82+ - name : Set Tailscale Architecture - Linux
7883 if : ${{ runner.os == 'Linux' }}
7984 shell : bash
80- env :
81- SHA256SUM : ${{ inputs.sha256sum }}
8285 run : |
8386 if [ ${{ runner.arch }} = "ARM64" ]; then
8487 TS_ARCH="arm64"
8992 else
9093 TS_ARCH="amd64"
9194 fi
95+ echo "TS_ARCH=$TS_ARCH" >> $GITHUB_ENV
96+
97+ - name : Set Tailscale Architecture - Windows
98+ if : ${{ runner.os == 'Windows' }}
99+ shell : bash
100+ run : |
101+ if [ ${{ runner.arch }} = "ARM64" ]; then
102+ TS_ARCH="arm64"
103+ elif [ ${{ runner.arch }} = "X86" ]; then
104+ TS_ARCH="x86"
105+ else
106+ TS_ARCH="amd64"
107+ fi
108+ echo "TS_ARCH=$TS_ARCH" >> $GITHUB_ENV
109+
110+ - name : Set SHA256 - Linux
111+ if : ${{ runner.os == 'Linux' }}
112+ shell : bash
113+ run : |
114+ MINOR=$(echo "$RESOLVED_VERSION" | awk -F '.' {'print $2'})
115+ if [ $((MINOR % 2)) -eq 0 ]; then
116+ URL="https://pkgs.tailscale.com/stable/tailscale_${RESOLVED_VERSION}_${TS_ARCH}.tgz.sha256"
117+ else
118+ URL="https://pkgs.tailscale.com/unstable/tailscale_${RESOLVED_VERSION}_${TS_ARCH}.tgz.sha256"
119+ fi
120+
121+ if [[ "${{ inputs.sha256sum }}" ]]; then
122+ SHA256SUM="${{ inputs.sha256sum }}"
123+ else
124+ SHA256SUM="$(curl -H user-agent:tailscale-github-action -L "${URL}" --fail)"
125+ fi
126+ echo "SHA256SUM=$SHA256SUM" >> $GITHUB_ENV
127+
128+ - name : Cache Tailscale Binary - Linux
129+ if : ${{ inputs.use-cache == 'true' && runner.os == 'Linux' }}
130+ uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
131+ id : cache-tailscale-linux
132+ with :
133+ path : tailscale.tgz
134+ key : ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ env.TS_ARCH }}-${{ env.SHA256SUM }}
135+
136+ - name : Download Tailscale - Linux
137+ if : ${{ runner.os == 'Linux' && (inputs.use-cache != 'true' || steps.cache-tailscale-linux.outputs.cache-hit != 'true') }}
138+ shell : bash
139+ run : |
92140 MINOR=$(echo "$RESOLVED_VERSION" | awk -F '.' {'print $2'})
93141 if [ $((MINOR % 2)) -eq 0 ]; then
94142 URL="https://pkgs.tailscale.com/stable/tailscale_${RESOLVED_VERSION}_${TS_ARCH}.tgz"
@@ -97,29 +145,48 @@ runs:
97145 fi
98146 echo "Downloading $URL"
99147 curl -H user-agent:tailscale-github-action -L "$URL" -o tailscale.tgz --max-time 300 --fail
100- if ! [[ "$SHA256SUM" ]] ; then
101- SHA256SUM="$(curl -H user-agent:tailscale-github-action -L "${URL}.sha256" --fail)"
102- fi
103148 echo "Expected sha256: $SHA256SUM"
104149 echo "Actual sha256: $(sha256sum tailscale.tgz)"
105150 echo "$SHA256SUM tailscale.tgz" | sha256sum -c
151+
152+ - name : Install Tailscale - Linux
153+ if : ${{ runner.os == 'Linux' }}
154+ shell : bash
155+ run : |
106156 tar -C /tmp -xzf tailscale.tgz
107- rm tailscale.tgz
108157 TSPATH=/tmp/tailscale_${RESOLVED_VERSION}_${TS_ARCH}
109158 sudo mv "${TSPATH}/tailscale" "${TSPATH}/tailscaled" /usr/bin
110- - name : Download Tailscale - Windows
159+
160+ - name : Set SHA256 - Windows
111161 if : ${{ runner.os == 'Windows' }}
112162 shell : bash
113- env :
114- SHA256SUM : ${{ inputs.sha256sum }}
115163 run : |
116- if [ ${{ runner.arch }} = "ARM64" ]; then
117- TS_ARCH="arm64"
118- elif [ ${{ runner.arch }} = "X86" ]; then
119- TS_ARCH="x86"
164+ MINOR=$(echo "$RESOLVED_VERSION" | awk -F '.' {'print $2'})
165+ if [ $((MINOR % 2)) -eq 0 ]; then
166+ URL="https://pkgs.tailscale.com/stable/tailscale-setup-${RESOLVED_VERSION}-${TS_ARCH}.msi.sha256"
120167 else
121- TS_ARCH="amd64 "
168+ URL="https://pkgs.tailscale.com/unstable/tailscale-setup-${RESOLVED_VERSION}-${TS_ARCH}.msi.sha256 "
122169 fi
170+
171+ if [[ "${{ inputs.sha256sum }}" ]]; then
172+ SHA256SUM="${{ inputs.sha256sum }}"
173+ else
174+ SHA256SUM="$(curl -H user-agent:tailscale-github-action -L "${URL}" --fail)"
175+ fi
176+ echo "SHA256SUM=$SHA256SUM" >> $GITHUB_ENV
177+
178+ - name : Cache Tailscale Binary - Windows
179+ if : ${{ inputs.use-cache == 'true' && runner.os == 'Windows' }}
180+ uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
181+ id : cache-tailscale-windows
182+ with :
183+ path : tailscale.msi
184+ key : ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ env.TS_ARCH }}-${{ env.SHA256SUM }}
185+
186+ - name : Download Tailscale - Windows
187+ if : ${{ runner.os == 'Windows' && (inputs.use-cache != 'true' || steps.cache-tailscale-windows.outputs.cache-hit != 'true') }}
188+ shell : bash
189+ run : |
123190 MINOR=$(echo "$RESOLVED_VERSION" | awk -F '.' {'print $2'})
124191 if [ $((MINOR % 2)) -eq 0 ]; then
125192 URL="https://pkgs.tailscale.com/stable/tailscale-setup-${RESOLVED_VERSION}-${TS_ARCH}.msi"
@@ -128,9 +195,6 @@ runs:
128195 fi
129196 echo "Downloading $URL"
130197 curl -H user-agent:tailscale-github-action -L "$URL" -o tailscale.msi --max-time 300 --fail
131- if ! [[ "$SHA256SUM" ]] ; then
132- SHA256SUM="$(curl -H user-agent:tailscale-github-action -L "${URL}.sha256" --fail)"
133- fi
134198 echo "Expected sha256: $SHA256SUM"
135199 echo "Actual sha256: $(sha256sum tailscale.msi)"
136200 echo "$SHA256SUM tailscale.msi" | sha256sum -c
@@ -140,16 +204,25 @@ runs:
140204 run : |
141205 Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
142206 Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
143- Remove-Item tailscale.msi -Force;
144207 - name : Checkout Tailscale repo - macOS
208+ id : checkout-tailscale-macos
145209 if : ${{ runner.os == 'macOS' }}
146210 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
147211 with :
148212 repository : tailscale/tailscale
149213 path : ${{ github.workspace }}/tailscale
150214 ref : v${{ env.RESOLVED_VERSION }}
215+ - name : Cache Tailscale - macOS
216+ if : ${{ inputs.use-cache == 'true' && runner.os == 'macOS' }}
217+ id : cache-tailscale-macos
218+ uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
219+ with :
220+ path : |
221+ /usr/local/bin/tailscale
222+ /usr/local/bin/tailscaled
223+ key : ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ runner.arch }}-${{ steps.checkout-tailscale-macos.outputs.commit }}
151224 - name : Build Tailscale binaries - macOS
152- if : ${{ runner.os == 'macOS' }}
225+ if : ${{ runner.os == 'macOS' && (inputs.use-cache != 'true' || steps.cache-tailscale-macos.outputs.cache-hit != 'true') }}
153226 shell : bash
154227 run : |
155228 cd tailscale
0 commit comments