Skip to content

Commit a825942

Browse files
authored
Add script to update esptool (#112)
***NO_CI***
1 parent 8d8ad98 commit a825942

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

update-esptool.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (c) .NET Foundation and Contributors
2+
# See LICENSE file in the project root for full license information.
3+
4+
# this PS1 downloads the latest version of the esptool from their github repo, unpacks it
5+
6+
# get details about latest version
7+
$lastRelease = $(gh release list --limit 1 --repo espressif/esptool)
8+
9+
# grab version
10+
$version = $lastRelease.Split()[3]
11+
12+
# make sure security doesn't block our request
13+
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11"
14+
15+
#############
16+
# WIN version
17+
$urlWin = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-win64.zip"
18+
$outputWin = "$env:TEMP\esptool-$version-win64.zip"
19+
20+
"Downloading esptool for Windows..." | Write-Host -ForegroundColor White -NoNewline
21+
(New-Object Net.WebClient).DownloadFile($urlWin, $outputWin)
22+
"OK" | Write-Host -ForegroundColor Green
23+
24+
#############
25+
# MAC version
26+
$urlMac = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-macos.zip"
27+
$outputMac = "$env:TEMP\esptool-$version-macos.zip"
28+
29+
"Downloading esptool for MAC..." | Write-Host -ForegroundColor White -NoNewline
30+
(New-Object Net.WebClient).DownloadFile($urlMac, $outputMac)
31+
"OK" | Write-Host -ForegroundColor Green
32+
33+
###############
34+
# Linux version
35+
$urlLinux = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-linux-amd64.zip"
36+
$outputLinux = "$env:TEMP\esptool-$version-linux-amd64.zip"
37+
38+
"Downloading esptool for Linux..." | Write-Host -ForegroundColor White -NoNewline
39+
(New-Object Net.WebClient).DownloadFile($urlLinux, $outputLinux)
40+
"OK" | Write-Host -ForegroundColor Green
41+
42+
# unzip files
43+
"Unzip files..." | Write-Host -ForegroundColor White -NoNewline
44+
Expand-Archive $outputWin -DestinationPath $env:TEMP -Force > $null
45+
Expand-Archive $outputMac -DestinationPath $env:TEMP -Force > $null
46+
Expand-Archive $outputLinux -DestinationPath $env:TEMP -Force > $null
47+
"OK" | Write-Host -ForegroundColor Green
48+
49+
# copy files to the correct locations
50+
"Copying files to tools folders..." | Write-Host -ForegroundColor White -NoNewline
51+
Move-Item -Path (Join-Path -Path $env:TEMP -ChildPath "esptool-$version-win64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolWin" -Resolve)
52+
Move-Item -Path (Join-Path -Path $env:TEMP -ChildPath "esptool-$version-macos\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolMac" -Resolve)
53+
Move-Item -Path (Join-Path -Path $env:TEMP -ChildPath "esptool-$version-linux-amd64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolLinux" -Resolve)
54+
"OK" | Write-Host -ForegroundColor Green
55+
56+
# cleanup files
57+
Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolWin\LICENSE" -Resolve) -Force
58+
Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolWin\README.md" -Resolve) -Force
59+
Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolMac\LICENSE" -Resolve) -Force
60+
Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolMac\README.md" -Resolve) -Force
61+
Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolLinux\LICENSE" -Resolve) -Force
62+
Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolLinux\README.md" -Resolve) -Force

0 commit comments

Comments
 (0)