Skip to content

Commit ac02d24

Browse files
authored
Merge pull request #103 from ManticSic/feature/99/nightly
Add nightly build
2 parents c3f2b9b + 441ff93 commit ac02d24

8 files changed

+163
-6
lines changed

.github/workflows/nightly.yml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Nightly Build
2+
3+
env:
4+
PACKAGE_ID: ExceptionalDevs.Exceptional.Nightly
5+
PACKAGE_TITLE: Exceptional for ReSharper (Nightly)
6+
7+
on:
8+
repository_dispatch:
9+
push:
10+
types: build-nightly
11+
schedule:
12+
- cron: '30 1 * * *'
13+
14+
jobs:
15+
build:
16+
name: Nightly Build
17+
runs-on: windows-latest
18+
steps:
19+
- uses: actions/checkout@v1
20+
with:
21+
ref: 'master'
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Checkout master
25+
if: success()
26+
run: git checkout master
27+
28+
- name: Precondition
29+
if: success()
30+
run: .\build\precondition.ps1
31+
32+
- name: Setup Environment Variables
33+
run: |
34+
$CurrentVersion = .\build\get-version.ps1
35+
$NupkgFileName = "${env:PACKAGE_ID}.${CurrentVersion}.nupkg"
36+
$NupkgFile = ".\build\packages\${NupkgFileName}"
37+
$TagName = "v${CurrentVersion}_nightly"
38+
echo "::set-env name=VERSION::$CurrentVersion"
39+
echo "::set-env name=NUPKG_FILE_NAME::$NupkgFileName"
40+
echo "::set-env name=NUPKG_FILE::$NupkgFile"
41+
echo "::set-env name=TAG_NAME::$TagName"
42+
43+
- name: Setup MSBuild
44+
uses: warrenbuckley/Setup-MSBuild@v1
45+
46+
- name: Setup Nuget
47+
uses: warrenbuckley/Setup-Nuget@v1
48+
49+
- name: Build
50+
if: success()
51+
run: |
52+
nuget restore ./src/Exceptional.sln
53+
msbuild ./src/Exceptional.sln /p:Configuration=Release /t:rebuild
54+
55+
- name: Pack
56+
if: success()
57+
run: nuget pack .\build\ExceptionalDevs.Exceptional.nuspec -OutputDirectory .\build\packages -properties "PackageId=${env:PACKAGE_ID};PackageTitle=${env:PACKAGE_TITLE}"
58+
59+
- name: Release
60+
id: create_release
61+
if: success()
62+
uses: actions/create-release@v1
63+
with:
64+
tag_name: ${{ env.TAG_NAME }}
65+
release_name: "Nightly Build (${{ env.VERSION }})"
66+
draft: false
67+
prerelease: true
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Upload Release Asset
72+
uses: actions/[email protected]
73+
with:
74+
upload_url: ${{ steps.create_release.outputs.upload_url }}
75+
asset_path: ${{ env.NUPKG_FILE }}
76+
asset_name: ${{ env.NUPKG_FILE_NAME }}
77+
asset_content_type: application/octet-stream
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
81+
- name: Update nightly.rev
82+
if: success()
83+
run: .\build\update-nightly-rev.ps1
84+
85+
- name: Increment Version
86+
if: success()
87+
run: .\build\increment-version.ps1 0.0.0.1
88+
89+
- name: Add & Commit
90+
if: success()
91+
run: |
92+
git config user.email [email protected]
93+
git config user.name "GitHub Actions"
94+
git commit -a -m "Nightly Commit" --author="GitHub Actions<[email protected]>"
95+
git status
96+
97+
- name: Git Push
98+
if: success()
99+
uses: ad-m/github-push-action@master
100+
with:
101+
github_token: ${{ secrets.GITHUB_TOKEN }}
102+
103+

build/02_CreatePackages.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nuget.exe pack ExceptionalDevs.Exceptional.nuspec -OutputDirectory "Packages"
1+
nuget.exe pack ExceptionalDevs.Exceptional.nuspec -OutputDirectory "Packages" -properties PackageId="ExceptionalDevs.Exceptional";PackageTitle="Exceptional for ReSharper"

build/ExceptionalDevs.Exceptional.nuspec

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<package>
33
<metadata>
4-
<id>ExceptionalDevs.Exceptional</id>
5-
<version>0.21.0.0</version>
6-
<title>Exceptional for ReSharper</title>
4+
<id>$PackageId$</id>
5+
<version>0.22.0.0</version>
6+
<title>$PackageTitle$</title>
77
<description>Analyzes thrown and documented C# exceptions and suggests improvements. </description>
88
<authors>ExceptionalDevs</authors>
99
<projectUrl>https://github.com/CSharpAnalyzers/ExceptionalReSharper</projectUrl>
10-
<copyright>Copyright &#x00A9; 2019 ExceptionalDevs</copyright>
10+
<copyright>Copyright © 2019 ExceptionalDevs</copyright>
1111
<tags>Exception XMLdoc</tags>
1212
<licenseUrl>https://github.com/CSharpAnalyzers/ExceptionalReSharper/blob/master/LICENSE.md</licenseUrl>
1313
<dependencies>

build/get-version.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
2+
$NuspecFile = Join-Path -Path $ScriptDir -ChildPath ExceptionalDevs.Exceptional.nuspec
3+
4+
$Xml = [xml](Get-Content $NuspecFile)
5+
$Version = New-Object -TypeName Version -ArgumentList $Xml.package.metadata.version
6+
7+
return $Version

build/increment-version.ps1

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Param([string]$VersionIncrementation)
2+
3+
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
4+
$GetVersionScript = Join-Path -Path $ScriptDir -ChildPath get-version.ps1
5+
$NuspecFile = Join-Path -Path $ScriptDir -ChildPath ExceptionalDevs.Exceptional.nuspec
6+
7+
$Incrementation = New-Object -TypeName Version -ArgumentList $VersionIncrementation
8+
$OldVersion = [Version](& $GetVersionScript)
9+
10+
$NewMajor = $OldVersion.Major + $Incrementation.Major
11+
$NewMinor = $OldVersion.Minor + $Incrementation.Minor
12+
$NewBuild = $OldVersion.Build + $Incrementation.Build
13+
$NewRevision = $OldVersion.Revision + $Incrementation.Revision
14+
15+
$NewVersion = New-Object -TypeName Version -ArgumentList ($NewMajor, $NewMinor, $NewBuild, $NewRevision)
16+
17+
$Xml = [xml](Get-Content $NuspecFile)
18+
$Xml.package.metadata.version = $NewVersion.ToString()
19+
$Xml.Save($NuspecFile)

build/nightly.rev

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6dc4e5f6f26cd605b8a7cff0788ca6b8b8489136

build/precondition.ps1

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
2+
$NightlyRevFile = Join-Path -Path $ScriptDir -ChildPath nightly.rev
3+
4+
$PreviousHash = git rev-parse HEAD~1
5+
$HashOfLatestBuild = Get-Content -Path $NightlyRevFile -ErrorAction SilentlyContinue
6+
7+
Write-Output "Previous hash: $PreviousHash"
8+
Write-Output "Latest Build Hash: $HashOfLatestBuild"
9+
10+
$HasChanges = -Not ($PreviousHash -eq $HashOfLatestBuild)
11+
12+
if ($HasChanges -eq $true)
13+
{
14+
"Some changes detected"
15+
exit 0
16+
}
17+
else
18+
{
19+
Write-Output "No changes detected"
20+
exit 1
21+
}

build/update-nightly-rev.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
2+
$NightlyRevFile = Join-Path -Path $ScriptDir -ChildPath nightly.rev
3+
4+
$GitRev = [string](git rev-parse HEAD)
5+
6+
Set-Content -Path $NightlyRevFile -Value ($GitRev)

0 commit comments

Comments
 (0)