Skip to content

Commit 5d53611

Browse files
mpminardioxtoacart
authored andcommitted
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. Also, on Windows, write `tailscale.log` to the temp dir. Also, on MacOS, delete the `tailscale` directory that was used to build the `tailscale(d)` commands. Updates: #170 Co-authored-by: Mario Minardi <[email protected]> Signed-off-by: Percy Wegmann <[email protected]>
1 parent 9a0fda8 commit 5d53611

File tree

2 files changed

+58
-13
lines changed

2 files changed

+58
-13
lines changed

.github/workflows/tailscale.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, windows-latest, macos-latest]
17+
cache: ['false', 'true']
1718
runs-on: ${{ matrix.os }}
1819
steps:
1920
- name: Check out code
@@ -25,8 +26,19 @@ jobs:
2526
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
2627
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
2728
tags: tag:ci
29+
use-cache: ${{ matrix.cache }}
2830

2931
- name: check for tailscale connection
3032
shell: bash
3133
run:
3234
tailscale status -json | jq -r .BackendState | grep -q Running
35+
36+
- name: ensure no dirty files from Tailscale Action remain
37+
shell: bash
38+
run: |
39+
extra_files=$(git ls-files . --exclude-standard --others)
40+
if [ ! -z "$extra_files" ]; then
41+
echo "::error::Unexpected extra files: $extra_files"
42+
exit 1
43+
fi
44+

action.yml

Lines changed: 46 additions & 13 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,12 +207,22 @@ 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: |
205-
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v tailscale.log', '/i', 'tailscale.msi')
223+
Start-Process "C:\Windows\System32\msiexec.exe" -Wait -ArgumentList @('/quiet', '/l*v ${{ runner.temp }}/tailscale.log', '/i', 'tailscale.msi')
206224
Add-Content $env:GITHUB_PATH "C:\Program Files\Tailscale\"
225+
Remove-Item tailscale.msi -Force;
207226
- name: Checkout Tailscale repo - macOS
208227
id: checkout-tailscale-macos
209228
if: ${{ runner.os == 'macOS' }}
@@ -212,24 +231,38 @@ runs:
212231
repository: tailscale/tailscale
213232
path: ${{ github.workspace }}/tailscale
214233
ref: v${{ env.RESOLVED_VERSION }}
215-
- name: Cache Tailscale - macOS
234+
- name: Restore Tailscale - macOS
216235
if: ${{ inputs.use-cache == 'true' && runner.os == 'macOS' }}
217-
id: cache-tailscale-macos
218-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
236+
id: restore-cache-tailscale-macos
237+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
219238
with:
220239
path: |
221240
/usr/local/bin/tailscale
222241
/usr/local/bin/tailscaled
223242
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: Remove tailscale checkout - macOS
253+
if: ${{ runner.os == 'macOS' }}
254+
shell: bash
255+
run: |
256+
rm -Rf ${{ github.workspace }}/tailscale
257+
- name: Save Tailscale - macOS
258+
if: ${{ inputs.use-cache == 'true' && runner.os == 'macOS' }}
259+
id: save-cache-tailscale-macos
260+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
261+
with:
262+
path: |
263+
/usr/local/bin/tailscale
264+
/usr/local/bin/tailscaled
265+
key: ${{ runner.os }}-tailscale-${{ env.RESOLVED_VERSION }}-${{ runner.arch }}-${{ steps.checkout-tailscale-macos.outputs.commit }}
233266
- name: Install timeout - macOS
234267
if: ${{ runner.os == 'macOS' }}
235268
shell: bash

0 commit comments

Comments
 (0)