Skip to content

Commit

Permalink
Merge pull request #3 from JPRuskin/tempretention
Browse files Browse the repository at this point in the history
Adds Build and Publish Steps
  • Loading branch information
steviecoaster authored Jul 9, 2021
2 parents 62a4fd8 + 1dd980b commit f1af643
Show file tree
Hide file tree
Showing 187 changed files with 637 additions and 343 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build NexuShell

on:
push:
branches-ignore:
- gh-pages
pull_request:
branches:
- main
- develop

workflow_dispatch:

jobs:
build:
runs-on: windows-latest
env:
NugetApiKey: ${{ secrets.PowerShellGalleryApiKey }}
ChocoApiKey: ${{ secrets.ChocolateyCommunityRepositoryApiKey }}

steps:
- uses: actions/checkout@v2

- name: GitVersion
id: gitversion
uses: PoshCode/Actions/gitversion@v1

- name: Install-RequiredModules
uses: PoshCode/Actions/install-requiredmodules@v1

- name: Build Module
run: .\build.ps1 -Build -SemVer "${{ steps.gitversion.outputs.LegacySemVerPadded }}"
shell: pwsh

- name: Upload Built Module
uses: actions/upload-artifact@v2
with:
name: NexuShell.${{ steps.gitversion.outputs.LegacySemVerPadded }}
path: .\Output

- name: Test Module
run: .\build.ps1 -TestPrePublish -SemVer "${{ steps.gitversion.outputs.LegacySemVerPadded }}"
shell: pwsh

- name: Upload Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v1
if: always()

- name: Create Release
if: ${{ github.ref == 'refs/heads/main' }}
continue-on-error: true
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: NexuShell v${{ steps.gitversion.outputs.MajorMinorPatch }}
tag_name: ${{ steps.gitversion.outputs.MajorMinorPatch }}
body: |
PowerShellGallery: [NexuShell ](https://www.powershellgallery.com/packages/NexuShell/${{ steps.gitversion.outputs.MajorMinorPatch }})
Chocolatey Community Repository: [NexuShell ](https://community.chocolatey.org/packages/NexuShell/${{ steps.gitversion.outputs.MajorMinorPatch }})
draft: false
prerelease: ${{ github.ref != 'refs/heads/main' }}

- name: Publish Module
if: ${{ github.ref == 'refs/heads/main' }}
run: .\build.ps1 -DeployToGallery -SemVer "${{ steps.gitversion.outputs.LegacySemVerPadded }}"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.DS_STORE
Output\*
Output
[0-9]\.[0-9]\.[0-9]
specifications
specifications\*
site\
site
site\*
site\*
TestResults.xml
Coverage.xml
4 changes: 4 additions & 0 deletions Build.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@{
ModuleManifest = ".\src\NexuShell.psd1"
SourceDirectories = "private", "public"
}
3 changes: 3 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mode: ContinuousDelivery
branches: {}
merge-message-formats: {}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# TreasureChest
# NexuShell

A PowerShell module for Sonatype Nexus repository server administration

## Try it out!

1. Clone this repo and run `.\build.ps1 -Build` from the cloned folder
2. Import the module with `Import-Module .\Output\TreasureChest\TreasureChest.psd1` from the cloned folder
3. Discover the available commands with `Get-Command -Module TreasureChest`
2. Import the module with `Import-Module .\Output\NexuShell\NexuShell.psd1` from the cloned folder
3. Discover the available commands with `Get-Command -Module NexuShell`
4. Explore the available commands with `Get-Help`
5. Start having fun!

### Documentation

Information about currently supported functions and their usage can be found on the [docs](https://steviecoaster.dev/TreasureChest/) site.
Information about currently supported functions and their usage can be found on the [docs](https://steviecoaster.dev/NexuShell/) site.
3 changes: 3 additions & 0 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
ModuleBuilder = "[2.0.0,3.0)"
}
17 changes: 17 additions & 0 deletions Requirements.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<#
.Synopsis
Installs prerequisites for building, testing, and publishing the module
#>
[CmdletBinding()]
param()

if (-not (Get-Command gitversion -ErrorAction SilentlyContinue)) {
# We use GitVersion to generate the version based on history in source control
choco install gitversion -y
}

if (-not ($Script = (Get-Command Install-RequiredModule -ErrorAction SilentlyContinue).Source)) {
$Install = Install-Script Install-RequiredModule -Force -PassThru
$Script = Join-Path $Install.InstalledLocation $Install.Name
}
& $Script -Path $PSScriptRoot\RequiredModules.psd1
Binary file removed TreasureChest.psd1
Binary file not shown.
95 changes: 43 additions & 52 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,88 +18,79 @@ param(

[Parameter()]
[Switch]
$Choco
)
$Choco,

[Parameter()]
[string]
$SemVer = $(
if (Get-Command gitversion -ErrorAction SilentlyContinue) {
(gitversion | ConvertFrom-Json).LegacySemVerPadded
}
)
)
process {

$root = Split-Path -Parent $MyInvocation.MyCommand.Definition

switch ($true) {
(-not $env:CI) {
. $PSScriptRoot\Requirements.ps1
}

$Build {
Build-Module -SemVer $SemVer
}

if (Test-Path "$root\Output") {
Remove-Item "$root\Output\TreasureChest\*.psm1" -Recurse -Force
} else {
$Null = New-Item "$root\Output" -ItemType Directory
$null = New-item "$root\Output\TreasureChest" -ItemType Directory
}

if (Test-Path "$root\src\nuget\tools\TreasureChest.zip") {
Remove-Item "$root\src\nuget\tools\TreasureChest.zip" -Force
}

Get-ChildItem $root\src\public -Recurse -Filter *.ps1 |
Foreach-Object {
Get-Content $_.FullName | Add-Content "$root\Output\TreasureChest\TreasureChest.psm1" -Force
}

Get-ChildItem $root\src\private\*.ps1 |
Foreach-Object {
Get-Content $_.FullName | Add-Content "$root\Output\TreasureChest\TreasureChest.psm1" -Force
$TestPrePublish {
if (Test-Path $root\Output\NexuShell) {
if ($env:PSModulePath.Split(';') -notcontains "$root\Output") {
$env:PSModulePath = "$root\Output;$env:PSModulePath"
}
Import-Module NexuShell
}

Copy-Item $root\TreasureChest.psd1 $root\Output\TreasureChest -Force

$TestArguments = @{
Path = "$root\tests"

}

$TestPrePublish {

Get-ChildItem $root\src\public\*.ps1, $root\Poshbot\*.ps1 |
Foreach-Object {
. $_.FullName
OutputFile = "$root\TestResults.xml"
OutputFormat = "JUnitXml"

CodeCoverage = (Get-ChildItem $root\Output\NexuShell -Recurse -Filter '*.ps*1').FullName
CodeCoverageOutputFile = "$root\Coverage.xml"
}
#Import-Module "$root\Output\TreasureChest\TreasureChest.psd1" -Force
Import-Module PoshBot -Force

Invoke-Pester "$root\tests\pre"

if (Test-Path $TestArguments.Path) {
Invoke-Pester @TestArguments
}
}

$TestPostPublish {

Install-Module TreasureChest -Force
Install-Module NexuShell -Force
Import-Module PoshBot -Force

Invoke-Pester "$root\tests\*.ps1"
}

$DeployToGallery {

Publish-Module -Path "$root\Output\TreasureChest" -NuGetApiKey $env:NugetApiKey

Publish-Module -Path "$root\Output\NexuShell" -NuGetApiKey $env:NugetApiKey
}

$Choco {

$Nuspec = Get-ChildItem "$root\src\nuget" -recurse -filter *.nuspec
$PackageSource = Join-Path $root "src\nuget"

if (Test-Path "$root\src\nuget\tools\TreasureChest.zip") {
choco pack $Nuspec.Fullname --output-directory $Nuspec.directory
}
$Nuspec = Get-ChildItem $PackageSource -recurse -filter *.nuspec

Copy-Item -Path $root\LICENSE -Destination $PackageSource
Compress-Archive -Path $root\Output\* -DestinationPath $PackageSource\tools\NexuShell.zip

else {
if (Test-Path "$PackageSource\tools\NexuShell.zip") {
choco pack $Nuspec.FullName --output-directory $root
} else {
throw "Welp, ya need the zip in the tools folder, dumby"
}
Get-ChildItem "$root\src\nuget" -recurse -filter *.nupkg |
Foreach-Object {

Get-ChildItem $PackageSource -recurse -filter *.nupkg | ForEach-Object {
choco push $_.FullName -s https://push.chocolatey.org --api-key="'$($env:ChocoApiKey)'"
}

}

}

}
4 changes: 2 additions & 2 deletions docs/Anonymous Auth/Get-NexusAnonymousAuthStatus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Anonymous Auth/Set-NexusAnonymousAuth.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Assets/Get-NexusAsset.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Assets/Remove-NexusAsset.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Blob Stores/Get-NexusBlobStore.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Blob Stores/Get-NexusBlobStoreQuota.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Blob Stores/New-NexusBlobStore.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Blob Stores/Remove-NexusBlobStore.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Certificates/Get-NexusCertificate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Certificates/New-NexusCertificate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Certificates/Remove-NexusCertificate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Components/New-NexusNugetComponent.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Components/New-NexusRawComponent.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
4 changes: 2 additions & 2 deletions docs/Connect-NexusServer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: TreasureChest-help.xml
Module Name: TreasureChest
external help file: NexuShell-help.xml
Module Name: NexuShell
online version:
schema: 2.0.0
---
Expand Down
Loading

0 comments on commit f1af643

Please sign in to comment.