-
Notifications
You must be signed in to change notification settings - Fork 20
172 lines (140 loc) · 5.91 KB
/
auto-deploy.yml
File metadata and controls
172 lines (140 loc) · 5.91 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Workflow to deploy a new command line tool release when a new tag is pushed
name: Build and Release
on:
push:
tags:
- '*'
jobs:
setup:
runs-on: windows-latest
defaults:
run:
shell: powershell
outputs:
tag_name: ${{ steps.getnames.outputs.tag }}
release_name: ${{ steps.getnames.outputs.release }}
steps:
- name: Checkout
uses: actions/checkout@v2
# Get tag name for new release
- name: Get Tag and Release Names
id: getnames
run: |
$tmp = '${{ github.ref }}'.split('/')
$tag = $tmp[$tmp.length-1]
$release = 'RealTimeKql ' + $tag
echo "::set-output name=tag::$tag"
echo "::set-output name=release::$release"
commandlinetool:
needs: setup
runs-on: windows-latest
defaults:
run:
shell: powershell
steps:
- name: Checkout
uses: actions/checkout@v2
# Run dotnet publish for all necessary binaries
- name: Publish Binaries
run: |
dotnet clean Source/KqlTools.sln
dotnet nuget locals all --clear
dotnet publish Source/RealTimeKql/RealTimeKql.csproj -r win-x64 -f netcoreapp3.1 -c Release -p:PublishSingleFile=true -o ${{ runner.temp }}\win-x64
dotnet publish Source/RealTimeKql/RealTimeKql.csproj -r linux-x64 -f netcoreapp3.1 -c Release -p:PublishSingleFile=true -o ${{ runner.temp }}\linux-x64
# Compress release packages for win-x64
- name: Compress Binaries Windows
run: |
mkdir ${{ github.workspace }}\ReleaseAssets
copy Doc/Queries/Windows/* ${{ runner.temp }}\win-x64
Compress-Archive -Path ${{ runner.temp }}\win-x64\* -DestinationPath "${{ github.workspace }}\ReleaseAssets\RealTimeKql.${{ env.TAG_NAME }}.zip"
# Compress release packages for linux-x64
- name: Compress Binaries Linux
run: |
copy Doc/Queries/Linux/* ${{ runner.temp }}\linux-x64
cd ReleaseAssets
tar -czvf "RealTimeKql.${{ env.TAG_NAME }}.tar.gz" ${{ runner.temp }}\linux-x64\*
# Upload compressed binaries to latest release
- name: Create Release Step
uses: ./Source/Actions/CreateReleaseAction
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.setup.outputs.tag_name }}
release_name: ${{ needs.setup.outputs.release_name }}
directory: '${{ github.workspace }}\ReleaseAssets'
pythonmodule:
needs: setup
runs-on: windows-latest
defaults:
run:
shell: powershell
env:
Identity_Mapper: "namita-prakash:${{ secrets.NAPRAKAS_PYPI_KEY }};" # Add mapping from github username to pypi api key secret
steps:
- name: Checkout
uses: actions/checkout@v2
# Get PyPi API key for current user
- name: Set API key
run: |
$ids = $env:Identity_Mapper -split ";"
$mapper = New-Object System.Collections.Generic.Dictionary"[String,String]"
foreach ($id in $ids) { $pair = $id -split ":"; $mapper.Add($pair[0],$pair[1]) }
$key = $mapper["${{ github.actor }}"]
echo "PYPI_API_KEY=$key" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Run dotnet publish for all necessary binaries
- name: Generate published dependencies
run: |
dotnet clean Source/KqlTools.sln
dotnet nuget locals all --clear
dotnet publish Source/RealTimeKqlLibrary/RealTimeKqlLibrary.csproj -r win-x64 -f net472 -c Release -o ${{ runner.temp }}\python\realtimekql\lib
# Set up python build directory
- name: Set up python build directory step
run: |
copy Source/KqlPython/* ${{ runner.temp }}\python\realtimekql
cd ${{ runner.temp }}\python\realtimekql
"${{ needs.setup.outputs.tag_name }}" | Out-File -FilePath VERSION.txt -Encoding ASCII -NoNewline
'directory = r"${{ runner.temp }}\python\realtimekql"' | Out-File -FilePath kqlpythondir.py -Encoding ASCII -NoNewline
# Build python wheel
- name: Build Python Wheel Step
run: |
cd ${{ runner.temp }}\python\realtimekql
python -m pip install -U pip wheel setuptools build
python -m build
# Deploy python module
- name: Deploy Python Module
run: |
cd ${{ runner.temp }}\python\realtimekql\
python -m pip install --user --upgrade twine
python -m twine upload dist\* -u __token__ -p $env:PYPI_API_KEY
powershellmodule:
needs: setup
runs-on: windows-latest
defaults:
run:
shell: powershell
env:
Identity_Mapper: "namita-prakash:${{ secrets.NAPRAKAS_POWERSHELL_API_KEY }};" # Add mapping from github username to powershell gallery api key secret
steps:
- name: Checkout
uses: actions/checkout@v2
# Get PyPi API key for current user
- name: Set API key
run: |
$ids = $env:Identity_Mapper -split ";"
$mapper = New-Object System.Collections.Generic.Dictionary"[String,String]"
foreach ($id in $ids) { $pair = $id -split ":"; $mapper.Add($pair[0],$pair[1]) }
$key = $mapper["${{ github.actor }}"]
echo "POWERSHELL_API_KEY=$key" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Run dotnet publish for all necessary binaries
- name: Generate published dependencies
run: |
dotnet clean Source/KqlTools.sln
dotnet nuget locals all --clear
dotnet publish Source/KqlPowerShell/KqlPowerShell.csproj -c Release -o ${{ runner.temp }}\powershell\RealTimeKql
# Generate module manifest & publish module
- name: Generate module manifest & publish module
run: |
copy Source/KqlPowerShell/RealTimeKql.psd1 ${{ runner.temp }}\powershell\RealTimeKql
cd ${{ runner.temp }}\powershell\RealTimeKql
Update-ModuleManifest RealTimeKql.psd1 -ModuleVersion ${{ needs.setup.outputs.tag_name }}
Test-ModuleManifest RealTimeKql.psd1
Publish-Module -Path ${{ runner.temp }}\powershell\RealTimeKql -NuGetApiKey $env:POWERSHELL_API_KEY