Skip to content

Commit 1e4b7be

Browse files
authored
Merge pull request #3 from PepperDash/feature/add-action
Feature/add action
2 parents 279a891 + b2d7c9d commit 1e4b7be

File tree

7 files changed

+273
-1
lines changed

7 files changed

+273
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: "[BUG]-"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**Stacktrace**
14+
15+
Include a stack trace of the exception if possible.
16+
```
17+
Paste stack trace here
18+
```
19+
20+
**To Reproduce**
21+
Steps to reproduce the behavior:
22+
1. Go to '...'
23+
2. Click on '....'
24+
3. Scroll down to '....'
25+
4. See error
26+
27+
**Expected behavior**
28+
A clear and concise description of what you expected to happen.
29+
30+
**Screenshots**
31+
If applicable, add screenshots to help explain your problem.
32+
33+
**Additional context**
34+
Add any other context about the problem here.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[FEATURE]-"
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
If this is a request for support for a new device or type, be as specific as possible and include any pertinent manufacturer and model information.
13+
14+
**Describe the solution you'd like**
15+
A clear and concise description of what you want to happen.
16+
17+
**Describe alternatives you've considered**
18+
A clear and concise description of any alternative solutions or features you've considered.
19+
20+
**Additional context**
21+
Add any other context or screenshots about the feature request here.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
$latestVersions = $(git tag --merged origin/master)
2+
$latestVersion = [version]"0.0.0"
3+
Foreach ($version in $latestVersions) {
4+
Write-Host $version
5+
try {
6+
if (([version]$version) -ge $latestVersion) {
7+
$latestVersion = $version
8+
Write-Host "Setting latest version to: $latestVersion"
9+
}
10+
} catch {
11+
Write-Host "Unable to convert $($version). Skipping"
12+
continue;
13+
}
14+
}
15+
16+
$newVersion = [version]$latestVersion
17+
$phase = ""
18+
$newVersionString = ""
19+
switch -regex ($Env:GITHUB_REF) {
20+
'^refs\/heads\/master*.' {
21+
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1)
22+
}
23+
'^refs\/heads\/feature\/*.' {
24+
$phase = 'alpha'
25+
}
26+
'^refs\/heads\/release\/*.' {
27+
$phase = 'rc'
28+
}
29+
'^refs\/heads\/development*.' {
30+
$phase = 'beta'
31+
}
32+
'^refs\/heads\/hotfix\/*.' {
33+
$phase = 'hotfix'
34+
}
35+
}
36+
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
37+
38+
Write-Output $newVersionString
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function Update-SourceVersion {
2+
Param ([string]$Version)
3+
#$fullVersion = $Version
4+
$baseVersion = [regex]::Match($Version, "(\d+.\d+.\d+).*").captures.groups[1].value
5+
$NewAssemblyVersion = AssemblyVersion(" + $baseVersion + .*")
6+
Write-Output "AssemblyVersion = $NewAssemblyVersion"
7+
$NewAssemblyInformationalVersion = AssemblyInformationalVersion(" + $Version + ")
8+
Write-Output "AssemblyInformationalVersion = $NewAssemblyInformationalVersion"
9+
10+
foreach ($o in $input) {
11+
Write-output $o.FullName
12+
$TmpFile = $o.FullName + .tmp
13+
get-content $o.FullName |
14+
ForEach-Object {
15+
$_ -replace AssemblyVersion\(".*"\), $NewAssemblyVersion } |
16+
ForEach-Object {
17+
$_ -replace AssemblyInformationalVersion\(".*"\), $NewAssemblyInformationalVersion
18+
} > $TmpFile
19+
move-item $TmpFile $o.FullName -force
20+
}
21+
}
22+
23+
function Update-AllAssemblyInfoFiles ( $version ) {
24+
foreach ($file in AssemblyInfo.cs, AssemblyInfo.vb ) {
25+
get-childitem -Path $Env:GITHUB_WORKSPACE -recurse | Where-Object { $_.Name -eq $file } | Update-SourceVersion $version ;
26+
}
27+
}
28+
29+
# validate arguments
30+
$r = [System.Text.RegularExpressions.Regex]::Match($args[0], "\d+\.\d+\.\d+.*");
31+
if ($r.Success) {
32+
Write-Output "Updating Assembly Version to $args ...";
33+
Update-AllAssemblyInfoFiles $args[0];
34+
}
35+
else {
36+
Write-Output ;
37+
Write-Output Error: Input version does not match x.y.z format!
38+
Write-Output ;
39+
Write-Output "Unable to apply version to AssemblyInfo.cs files";
40+
}

.github/scripts/ZipBuildOutput.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Uncomment these for local testing
2+
# $Env:GITHUB_WORKSPACE = "C:\Working Directories\PD\essentials"
3+
# $Env:SOLUTION_FILE = "PepperDashEssentials"
4+
# $Env:VERSION = "0.0.0-buildType-test"
5+
6+
# Sets the root directory for the operation
7+
$destination = "$($Env:GITHUB_HOME)\output"
8+
New-Item -ItemType Directory -Force -Path ($destination)
9+
Get-ChildItem ($destination)
10+
$exclusions = @(git submodule foreach --quiet 'echo $name')
11+
# Trying to get any .json schema files (not currently working)
12+
# Gets any files with the listed extensions.
13+
Get-ChildItem -recurse -Path "$($Env:GITHUB_WORKSPACE)" -include "*.clz", "*.cpz", "*.cplz" | ForEach-Object {
14+
$allowed = $true;
15+
# Exclude any files in submodules
16+
foreach ($exclude in $exclusions) {
17+
if ((Split-Path $_.FullName -Parent).contains("$($exclude)")) {
18+
$allowed = $false;
19+
break;
20+
}
21+
}
22+
if ($allowed) {
23+
Write-Host "allowing $($_)"
24+
$_;
25+
}
26+
} | Copy-Item -Destination ($destination) -Force
27+
Write-Host "Getting matching files..."
28+
# Get any files from the output folder that match the following extensions
29+
Get-ChildItem -Path $destination | Where-Object {($_.Extension -eq ".clz") -or ($_.Extension -eq ".cpz" -or ($_.Extension -eq ".cplz"))} | ForEach-Object {
30+
# Replace the extensions with dll and xml and create an array
31+
$filenames = @($($_ -replace "cpz|clz|cplz", "dll"), $($_ -replace "cpz|clz|cplz", "xml"))
32+
Write-Host "Filenames:"
33+
Write-Host $filenames
34+
if ($filenames.length -gt 0) {
35+
# Attempt to get the files and return them to the output directory
36+
Get-ChildItem -Recurse -Path "$($Env:GITHUB_WORKSPACE)" -include $filenames | Copy-Item -Destination ($destination) -Force
37+
}
38+
}
39+
Compress-Archive -Path $destination -DestinationPath "$($Env:GITHUB_WORKSPACE)\$($Env:SOLUTION_FILE)-$($Env:VERSION).zip" -Force
40+
Write-Host "Output Contents post Zip"
41+
Get-ChildItem -Path $destination

.github/workflows/docker.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Branch Build Using Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- feature/*
7+
- hotfix/*
8+
- release/*
9+
- master
10+
- development
11+
12+
env:
13+
# solution path doesn't need slashes unless there it is multiple folders deep
14+
# solution name does not include extension. .sln is assumed
15+
SOLUTION_PATH: PDT.EssentialsPluginTemplate.EPI
16+
SOLUTION_FILE: PDT.EssentialsPluginTemplate.EPI
17+
# Do not edit this, we're just creating it here
18+
VERSION: 0.0.0-buildtype-buildnumber
19+
# Defaults to debug for build type
20+
BUILD_TYPE: Debug
21+
# Defaults to master as the release branch. Change as necessary
22+
RELEASE_BRANCH: master
23+
jobs:
24+
Build_Project:
25+
runs-on: windows-latest
26+
steps:
27+
# First we checkout the source repo
28+
- name: Checkout repo
29+
uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
# And any submodules
33+
- name: Checkout submodules
34+
shell: bash
35+
run: |
36+
git config --global url."https://github.com/".insteadOf "[email protected]:"
37+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
38+
git submodule sync --recursive
39+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
40+
# Set the BUILD_TYPE environment variable
41+
- name: Set Build to Release if triggered from Master
42+
run: |
43+
if("$($Env:GITHUB_REF)".contains("$($Env:RELEASE_BRANCH)")) {
44+
Write-Host "Setting build type to Release"
45+
Write-Output "::set-env name=BUILD_TYPE::Release"
46+
}
47+
# Fetch all tags
48+
- name: Fetch tags
49+
run: git fetch --tags
50+
# Generate the appropriate version number
51+
- name: Set Version Number
52+
shell: powershell
53+
run: |
54+
$version = ./.github/scripts/GenerateVersionNumber.ps1
55+
Write-Output "::set-env name=VERSION::$version"
56+
# Use the version number to set the version of the assemblies
57+
- name: Update AssemblyInfo.cs
58+
shell: powershell
59+
run: |
60+
Write-Output ${{ env.VERSION }}
61+
./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
62+
# Build the solutions in the docker image
63+
- name: Build Solution
64+
shell: powershell
65+
run: |
66+
Invoke-Expression "docker run --rm --mount type=bind,source=""$($Env:GITHUB_WORKSPACE)"",target=""c:/project"" pepperdash/sspbuilder c:\cihelpers\vsidebuild.exe -Solution ""c:\project\$($Env:SOLUTION_PATH)\$($Env:SOLUTION_FILE).sln"" -BuildSolutionConfiguration $($ENV:BUILD_TYPE)"
67+
# Zip up the output files as needed
68+
- name: Zip Build Output
69+
shell: powershell
70+
run: ./.github/scripts/ZipBuildOutput.ps1
71+
- name: Upload Build Output
72+
uses: actions/upload-artifact@v1
73+
with:
74+
name: Build
75+
path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
76+
# Create the release on the source repo
77+
- name: Create Release
78+
id: create_release
79+
uses: actions/create-release@v1
80+
with:
81+
tag_name: ${{ env.VERSION }}
82+
release_name: ${{ env.VERSION }}
83+
prerelease: ${{contains('debug', env.BUILD_TYPE)}}
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
# Upload the build package to the release
87+
- name: Upload Release Package
88+
id: upload_release
89+
uses: actions/upload-release-asset@v1
90+
with:
91+
upload_url: ${{ steps.create_release.outputs.upload_url }}
92+
asset_path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
93+
asset_name: ${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
94+
asset_content_type: application/zip
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Essentials Plugin Template (c) 2020
22

33
## License
4+
45
Provided under MIT license
56

67
## Overview
78

8-
Fork this repo when creating a new plugin for Essentials. For more information about plugins, refer to the Essentials Wiki [Plugins](https://github.com/PepperDash/Essentials/wiki/Plugins) article.
9+
Fork this repo when creating a new plugin for Essentials. For more information about plugins, refer to the Essentials Wiki [Plugins](https://github.com/PepperDash/Essentials/wiki/Plugins) article.
910

11+
This repo contains a Github Action workflow that will build this project automatically. Modify the SOLUTION_PATH and SOLUTION_FILE environment variables as needed.

0 commit comments

Comments
 (0)