-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrelease.bat
More file actions
71 lines (60 loc) · 2.6 KB
/
Copy pathrelease.bat
File metadata and controls
71 lines (60 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@echo off
setlocal
rem Publishes a release from GitHub Actions, without building anything locally.
rem The tag and the NuGet packages both take the Version in Directory.Build.props, so bump that first.
rem A version that is already released or already on nuget.org stops the run before anything is published.
rem GitHub builds what is pushed, not what is on this machine, so commit and push first.
rem
rem Needs the GitHub CLI, https://cli.github.com, signed in with "gh auth login",
rem and a nuget.org Trusted Publishing policy for the push, see docs\MAINTENANCE.md.
rem The workflow also has to exist on the default branch, which is where GitHub looks for it.
rem
rem release.bat builds every sample for every architecture, pushes the packages and publishes the release.
rem release.bat build builds and packs only, the zips and the packages stay as artifacts of the run.
rem build.bat does the same.
set RESULT=0
set RELEASE=true
if /i "%~1"=="build" set RELEASE=false
where gh >nul 2>&1
if errorlevel 1 (
echo the GitHub CLI is needed. see https://cli.github.com
set RESULT=1
goto done
)
set VERSION=
for /f "tokens=3 delims=<>" %%v in ('findstr /c:"<Version>" "%~dp0Directory.Build.props"') do if not defined VERSION set VERSION=%%v
if "%VERSION%"=="" (
echo no ^<Version^> found in Directory.Build.props
set RESULT=1
goto done
)
set AHEAD=0
for /f %%n in ('git -C "%~dp0." rev-list --count "@{u}..HEAD" 2^>nul') do set AHEAD=%%n
if not "%AHEAD%"=="0" echo warning: %AHEAD% local commit^(s^) not pushed, GitHub builds what is pushed, not those.
if "%RELEASE%"=="true" (
echo this publishes AOTrino and AOTrino.Templates %VERSION% to nuget.org, and the GitHub release v%VERSION%.
choice /c yn /m "go ahead"
if errorlevel 2 goto done
) else (
echo building and packing %VERSION%, nothing is published.
)
echo starting the workflow with release=%RELEASE%
gh workflow run release.yml -f release=%RELEASE%
if errorlevel 1 (
set RESULT=1
goto done
)
rem the run takes a moment to be queued before it can be found.
timeout /t 6 /nobreak >nul
set RUNID=
for /f "delims=" %%i in ('gh run list --workflow=release.yml --limit 1 --json databaseId --jq ".[0].databaseId"') do set RUNID=%%i
if "%RUNID%"=="" (
echo the run was started but could not be found. see it at the Actions tab.
goto done
)
gh run watch %RUNID% --exit-status
if errorlevel 1 set RESULT=1
:done
rem a double click runs this through "cmd /c", which closes the window as soon as it ends, before anything can be read.
echo %cmdcmdline% | findstr /i /c:" /c " >nul && pause
exit /b %RESULT%