Skip to content

Commit c4116f9

Browse files
author
sebastian gomez
authored
Create GitHub build action
1 parent 9415eb4 commit c4116f9

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/main.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
8+
jobs:
9+
build:
10+
runs-on: windows-2019
11+
12+
env:
13+
Configuration: Release
14+
Project: MQTTLib
15+
Solution: MQTTLib.sln
16+
Bin: MQTTLib.dll
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
# setup MSBuild
22+
- name: setup-msbuild
23+
uses: microsoft/setup-msbuild@v1
24+
25+
- name: Setup NuGet.exe
26+
uses: nuget/setup-nuget@v1
27+
28+
# Runs a multiple command using the runners shell
29+
- name: Restore Nuget
30+
run: Nuget restore ${env:Solution}
31+
32+
# Runs a multiple command using the runners shell
33+
- name: Build Solution
34+
run: msbuild ${env:Solution} /p:Configuration=${env:Configuration}
35+
36+
- name: Set the version environment variable
37+
run: |
38+
$file = ".\src\MQTTLib\bin\${env:Configuration}\${env:Bin}"
39+
$env:WINS_VERSION = $(Get-Item $file).VersionInfo.ProductVersion
40+
Write-Host WINS_VERSION $env:WINS_VERSION
41+
echo "::set-env name=WINS_VERSION::$env:WINS_VERSION"
42+
$env:TIMESTAMP = Get-Date -Format "yyyyMMddHHmmss"
43+
Write-Host TIMESTAMP $env:TIMESTAMP
44+
echo "::set-env name=TIMESTAMP::$env:TIMESTAMP"
45+
- name: Deploy & zip
46+
run: |
47+
New-Item bin -ItemType Directory
48+
49+
Copy-Item .\src\MQTTLib\bin\${env:Configuration}\MQTTLib.dll .\bin
50+
Copy-Item .\src\MQTTLib\bin\${env:Configuration}\MQTTnet.dll .\bin
51+
Copy-Item .\src\MQTTLib\bin\${env:Configuration}\BouncyCastle.Crypto.dll .\bin
52+
53+
Compress-Archive -Path .\bin\*.* -DestinationPath ${{ env.Project }}.zip
54+
55+
- name: Create a Release
56+
id: create_release
57+
uses: actions/create-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
60+
with:
61+
tag_name: ${{ env.TIMESTAMP }}
62+
release_name: Release ${{ env.TIMESTAMP }} (${{ env.Project }} ${{ env.WINS_VERSION }})
63+
64+
- name: Upload Release Asset
65+
id: upload-release-asset
66+
uses: actions/upload-release-asset@v1
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
with:
70+
upload_url: ${{ steps.create_release.outputs.upload_url }}
71+
asset_path: ./${{ env.Project }}.zip
72+
asset_name: ${{ env.Project }}.zip
73+
asset_content_type: application/zip

0 commit comments

Comments
 (0)