-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a16f69
commit ede3f51
Showing
6 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Milestone Closure Trigger | ||
|
||
on: | ||
milestone: | ||
types: [closed] | ||
|
||
jobs: | ||
create-release-notes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
# Your additional steps go here. For example: | ||
- name: Create Release Notes | ||
uses: mod-posh/[email protected] | ||
with: | ||
milestone_number: ${{ github.event.milestone.number }} | ||
verbose: 'verbose' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: C-Sharp Project Workflow | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
Build: | ||
name: Build, Test and Package | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.x | ||
- name: Install DefaultDocumentation | ||
run: dotnet tool install DefaultDocumentation.Console -g | ||
- name: Clean Project | ||
run: | | ||
$projectPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'CSharpProject' | ||
$outputPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Output' | ||
$docsPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Docs' | ||
dotnet clean $projectPath --nologo -c Debug | ||
dotnet clean $projectPath --nologo -c Release | ||
$null = Remove-Item $outputPath -Recurse -ErrorAction Ignore | ||
$null = New-Item -Type Directory -Path $outputPath -ErrorAction Ignore | ||
$null = New-Item -Type Directory -Path $docsPath -ErrorAction Ignore | ||
- name: Test Project | ||
run: | | ||
$projectPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'CSharpProject.Tests' | ||
dotnet test $projectPath --nologo | ||
- name: Build Project | ||
run: | | ||
$projectPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'CSharpProject' | ||
$outputPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Output' | ||
dotnet build $projectPath -o $outputPath | ||
Get-ChildItem -Path $outputPath | ||
- name: Create Documentation | ||
run: | | ||
$outputPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Output' | ||
$docsPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Docs' | ||
defaultdocumentation -a $outputPath\CSharpProject.dll -o $docsPath | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
git commit -m "Document updates" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
uses: mod-posh/[email protected] | ||
with: | ||
name: '"Our latest awesome release"' | ||
version: '"2.0.4"' | ||
verbose: "verbose" | ||
body: '"This release adds some features."' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,45 @@ | ||
# modposh-template | ||
# Get Project Version GitHub Action | ||
|
||
## Overview | ||
|
||
The GetProjectVersion Action returns the current version of your project based on the version of a given project file. There are currently only two file types supported: | ||
|
||
1. .csproj - C-Sharp project files | ||
2. .psd1 - PowerShell Module Manifest files | ||
|
||
## Workflow File | ||
|
||
You can trigger the `action.yml` by `workflow_call` to post a notification automatically. The workflow contains several steps to act: | ||
|
||
1. Checkout the repository | ||
2. Call the `getprojectversion.ps1` script | ||
|
||
### Workflow Inputs | ||
|
||
- `Filename`: If the file is in the root of the repository, it's just the filename, project.csproj. If the file is inside a folder, it's the relative path to that file, MyProject\project.psd1 | ||
- `verbose`: A value of verbose will output additional information | ||
|
||
## PowerShell Script (`getprojectversion.ps1`) | ||
|
||
The PowerShell script opens the given project file and returns the string value of the version. | ||
|
||
## Usage | ||
|
||
There are a few different ways you could use this action; here is an example of one way to get you started. | ||
|
||
```yaml | ||
jobs: | ||
GetVersion: | ||
uses: mod-posh/[email protected] | ||
with: | ||
Filename: '"MyModule.psd1"' | ||
verbose: 'verbose' | ||
``` | ||
> [!Note] | ||
> This example is used directly as part of a larger workflow | ||
> The verbose option will output a little more detail in the logs | ||
## License | ||
This project is licensed using the [Gnu GPL-3](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: 'GetProjectVersion' | ||
description: 'Get the current version of your project' | ||
author: 'Jeff Patton' | ||
|
||
branding: | ||
icon: 'bell' | ||
color: 'blue' | ||
|
||
inputs: | ||
Filename: | ||
description: 'The filename of the project or relative path to the project file' | ||
required: true | ||
type: string | ||
verbose: | ||
description: "A value of verbose will output additional information" | ||
required: false | ||
type: string | ||
default: 'None' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Project Version | ||
env: | ||
VERBOSE: ${{ inputs.verbose }} | ||
run: | | ||
$Version = & $env:GITHUB_ACTION_PATH\\getprojectversion.ps1 -Filename ${{ inputs.Filename }} | ||
echo "::set-output name=Version::$Version" | ||
shell: pwsh | ||
id: GetProjectVersion | ||
outputs: | ||
version: ${{ steps.GetProjectVersion.outputs.Version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
param ( | ||
[string]$Filename | ||
) | ||
try { | ||
$ErrorActionPreference = 'Stop'; | ||
$Error.Clear(); | ||
$sourcePath = $env:GITHUB_WORKSPACE | ||
|
||
|
||
if ($verbose.ToLower() -eq 'verbose') | ||
{ | ||
Write-Host "GetProjectVersion DEBUG" | ||
Write-Host "Filename : $($Filename)" | ||
Write-Host "SourcePath : $($sourcePath)" | ||
} | ||
|
||
$File = Get-Item -Path (Join-Path -Path $sourcePath -ChildPath $FileName) | ||
switch ($File.Extension) | ||
{ | ||
'.csproj' | ||
{ | ||
$Project = [xml](Get-Content -Path $File.FullName); | ||
$Version = $Project.Project.PropertyGroup.Version.ToString(); | ||
} | ||
'.psd1' | ||
{ | ||
$Manifest = Test-ModuleManifest -Path $File.FullName -ErrorAction SilentlyContinue | ||
$Version = $Manifest.Version.ToString() | ||
} | ||
default | ||
{ | ||
throw "The extension, $($File.Extension) is not currently a supported type, please create an issue to address this" | ||
} | ||
} | ||
|
||
if ($verbose.ToLower() -eq 'verbose') | ||
{ | ||
Write-Host "Extension : $($File.Extension)" | ||
Write-Host "Version : $($Version)" | ||
} | ||
|
||
return $Version | ||
} catch { | ||
$_.InvocationInfo | Out-String; | ||
throw $_.Exception.Message; | ||
} |