Skip to content

Commit 9f197fa

Browse files
committed
action.yml: properly remove temporary files after downloading
Remove `.tgz` and `.msi` files after they have been downloaded. This was the behaviour of the action previous to `v3.2.0`, but our logic for caching removed the deletion of these files. Can look at downloading these to temp folders to avoid the more complex logic here as a follow up, but this should unblock / fix the immediate regression. Updates #TODO Signed-off-by: Mario Minardi <mario@tailscale.com>
1 parent 9a0fda8 commit 9f197fa

File tree

2 files changed

+49
-20
lines changed

2 files changed

+49
-20
lines changed

.github/workflows/tailscale.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- main
7+
- 'mpminardi/remove-temp-files'
88
pull_request:
99
branches:
1010
- '*'
@@ -25,6 +25,7 @@ jobs:
2525
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
2626
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
2727
tags: tag:ci
28+
use-cache: 'true'
2829

2930
- name: check for tailscale connection
3031
shell: bash

action.yml

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ runs:
125125
fi
126126
echo "SHA256SUM=$SHA256SUM" >> $GITHUB_ENV
127127
128-
- name: Cache Tailscale Binary - Linux
128+
- name: Restore Tailscale Binary - Linux
129129
if: ${{ inputs.use-cache == 'true' && runner.os == 'Linux' }}
130-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
131-
id: cache-tailscale-linux
130+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
131+
id: restore-cache-tailscale-linux
132132
with:
133133
path: tailscale.tgz
134134
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ env.TS_ARCH }}-${{ env.SHA256SUM }}
135135

136136
- name: Download Tailscale - Linux
137-
if: ${{ runner.os == 'Linux' && (inputs.use-cache != 'true' || steps.cache-tailscale-linux.outputs.cache-hit != 'true') }}
137+
if: ${{ runner.os == 'Linux' && (inputs.use-cache != 'true' || steps.restore-cache-tailscale-linux.outputs.cache-hit != 'true') }}
138138
shell: bash
139139
run: |
140140
MINOR=$(echo "$RESOLVED_VERSION" | awk -F '.' {'print $2'})
@@ -148,12 +148,21 @@ runs:
148148
echo "Expected sha256: $SHA256SUM"
149149
echo "Actual sha256: $(sha256sum tailscale.tgz)"
150150
echo "$SHA256SUM tailscale.tgz" | sha256sum -c
151+
152+
- name: Save Tailscale Binary - Linux
153+
if: ${{ inputs.use-cache == 'true' && steps.restore-cache-tailscale-linux.outputs.cache-hit != 'true' && runner.os == 'Linux' }}
154+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
155+
id: save-cache-tailscale-linux
156+
with:
157+
path: tailscale.tgz
158+
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ env.TS_ARCH }}-${{ env.SHA256SUM }}
151159

152160
- name: Install Tailscale - Linux
153161
if: ${{ runner.os == 'Linux' }}
154162
shell: bash
155163
run: |
156164
tar -C /tmp -xzf tailscale.tgz
165+
rm tailscale.tgz
157166
TSPATH=/tmp/tailscale_${RESOLVED_VERSION}_${TS_ARCH}
158167
sudo mv "${TSPATH}/tailscale" "${TSPATH}/tailscaled" /usr/bin
159168
@@ -175,16 +184,16 @@ runs:
175184
fi
176185
echo "SHA256SUM=$SHA256SUM" >> $GITHUB_ENV
177186
178-
- name: Cache Tailscale Binary - Windows
187+
- name: Restore Tailscale Binary - Windows
179188
if: ${{ inputs.use-cache == 'true' && runner.os == 'Windows' }}
180-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
181-
id: cache-tailscale-windows
189+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
190+
id: restore-cache-tailscale-windows
182191
with:
183192
path: tailscale.msi
184193
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ env.TS_ARCH }}-${{ env.SHA256SUM }}
185194

186195
- name: Download Tailscale - Windows
187-
if: ${{ runner.os == 'Windows' && (inputs.use-cache != 'true' || steps.cache-tailscale-windows.outputs.cache-hit != 'true') }}
196+
if: ${{ runner.os == 'Windows' && (inputs.use-cache != 'true' || steps.restore-cache-tailscale-windows.outputs.cache-hit != 'true') }}
188197
shell: bash
189198
run: |
190199
MINOR=$(echo "$RESOLVED_VERSION" | awk -F '.' {'print $2'})
@@ -198,38 +207,57 @@ runs:
198207
echo "Expected sha256: $SHA256SUM"
199208
echo "Actual sha256: $(sha256sum tailscale.msi)"
200209
echo "$SHA256SUM tailscale.msi" | sha256sum -c
210+
211+
- name: Save Tailscale Binary - Windows
212+
if: ${{ inputs.use-cache == 'true' && steps.restore-cache-tailscale-windows.outputs.cache-hit != 'true' && runner.os == 'Windows' }}
213+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
214+
id: save-cache-tailscale-windows
215+
with:
216+
path: tailscale.msi
217+
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ env.TS_ARCH }}-${{ env.SHA256SUM }}
218+
201219
- name: Install Tailscale - Windows
202220
if: ${{ runner.os == 'Windows' }}
203221
shell: pwsh
204222
run: |
205223
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
206224
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
225+
Remove-Item tailscale.msi -Force;
226+
- name: Restore Tailscale - macOS
227+
if: ${{ inputs.use-cache == 'true' && runner.os == 'macOS' }}
228+
id: restore-cache-tailscale-macos
229+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
230+
with:
231+
path: |
232+
/usr/local/bin/tailscale
233+
/usr/local/bin/tailscaled
234+
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ runner.arch }}-${{ steps.checkout-tailscale-macos.outputs.commit }}
207235
- name: Checkout Tailscale repo - macOS
208236
id: checkout-tailscale-macos
209-
if: ${{ runner.os == 'macOS' }}
237+
if: ${{ runner.os == 'macOS' && (inputs.use-cache != 'true' || steps.restore-cache-tailscale-macos.outputs.cache-hit != 'true') }}
210238
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
211239
with:
212240
repository: tailscale/tailscale
213241
path: ${{ github.workspace }}/tailscale
214242
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 }}
224243
- name: Build Tailscale binaries - macOS
225-
if: ${{ runner.os == 'macOS' && (inputs.use-cache != 'true' || steps.cache-tailscale-macos.outputs.cache-hit != 'true') }}
244+
if: ${{ runner.os == 'macOS' && (inputs.use-cache != 'true' || steps.restore-cache-tailscale-macos.outputs.cache-hit != 'true') }}
226245
shell: bash
227246
run: |
228247
cd tailscale
229248
export TS_USE_TOOLCHAIN=1
230249
./build_dist.sh ./cmd/tailscale
231250
./build_dist.sh ./cmd/tailscaled
232251
sudo mv tailscale tailscaled /usr/local/bin
252+
- name: Save Tailscale - macOS
253+
if: ${{ inputs.use-cache == 'true' && runner.os == 'macOS' }}
254+
id: save-cache-tailscale-macos
255+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
256+
with:
257+
path: |
258+
/usr/local/bin/tailscale
259+
/usr/local/bin/tailscaled
260+
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ runner.arch }}-${{ steps.checkout-tailscale-macos.outputs.commit }}
233261
- name: Install timeout - macOS
234262
if: ${{ runner.os == 'macOS' }}
235263
shell: bash

0 commit comments

Comments
 (0)