Skip to content

Commit

Permalink
feat+: rewrite to be semver compliant (#5)
Browse files Browse the repository at this point in the history
* feat: rewrite to be semver compliant

* fix: add import module pester

* fix: add missing output type
  • Loading branch information
ArwynFr authored May 28, 2023
1 parent 280e78e commit 7a19277
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 283 deletions.
3 changes: 0 additions & 3 deletions .github/CODE_OF_CONDUCT.md

This file was deleted.

3 changes: 0 additions & 3 deletions .github/CONTRIBUTING.md

This file was deleted.

Empty file removed .github/ISSUE_TEMPLATE.md
Empty file.
Empty file removed .github/PULL_REQUEST_TEMPLATE.md
Empty file.
36 changes: 36 additions & 0 deletions .github/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
= StepSemVer

StepSemVer is a small powershell module that adds a command to increment semantic version numbers.

image:https://img.shields.io/powershellgallery/v/StepSemVer?style=for-the-badge[PowerShell Gallery] image:https://img.shields.io/powershellgallery/dt/StepSemVer?style=for-the-badge[PowerShell Gallery]

== Rules and standards

The following documents provide additional information on rules and standards applying to this project :

- link:/LICENSE[MIT License]

== How to use the module

This module contains a single command :

=== Step-SemVer

Returns a semantic version that increments an existing value.

```Powershell
Step-SemVer
[[-Version] <semver>]
[-BumpType] {major | minor | patch}
[[-PreRelease] <string>]
[[-Build] <string>]
[<CommonParameters>]
```

`-Version`:: *Required* and *Pipelinable*. Current version from which to do the increment.

`-BumpType`:: *Required*. Must be one of `major`, `minor`, or `patch`. The new version number is incremented based on this value.

`-PreRelease`:: *Optional*. If specified, sets the pre-release value of the new version.

`-Build`:: *Optional*. If specified, sets the build value of the new version.
55 changes: 0 additions & 55 deletions .github/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/continuous-integration.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: continuous integration

on:
workflow_dispatch:
push:
branches: [main]

jobs:
deployment:
runs-on: ubuntu-latest
steps:

- name: Checkout source files
uses: actions/checkout@v3

- name: Get new version
uses: arwynfr/actions-conventional-versioning/get-newVersion@v1
id: new-version

- name: Update module manifest version
shell: pwsh
run: Update-ModuleManifest -ModuleVersion ${{ steps.new-version.outputs.next-version }} ./StepSemVer/StepSemVer.psd1

- name: Publish module on PSGallery
shell: pwsh
run: Publish-Module -Path ./StepSemVer/ -NuGetApiKey ${{ secrets.PSGALLERY_APIKEY }}

- name: Tag new version on the repository
uses: arwynfr/actions-conventional-versioning@v1
22 changes: 22 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: continuous integration

on:
workflow_dispatch:
pull_request:
branches: [main]

jobs:
integration:
runs-on: ubuntu-latest
steps:

- name: Checkout source files
uses: actions/checkout@v3

- name: Lint sources
shell: pwsh
run: Invoke-ScriptAnalyzer -Recurse -Severity Warning ./StepSemVer/

- name: Run unit tests
shell: pwsh
run: ./build/test.ps1
2 changes: 1 addition & 1 deletion StepSemVer/StepSemVer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

GUID = 'b4209e98-7072-45f3-bb89-ce520a182558'
Description = 'A powerhsell module dedicated to incrementing SemVer versions'
ModuleVersion = '0.0.0.1'
ModuleVersion = '0.1.0'
HelpInfoURI = 'https://www.gsri.team'

RootModule = 'StepSemVer.psm1'
Expand Down
36 changes: 35 additions & 1 deletion StepSemVer/StepSemVer.psm1
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
Get-ChildItem $PSScriptRoot\functions -Filter *.ps1 | ForEach-Object { . $_.FullName }
function Step-SemVer {
[CmdletBinding()]
[OutputType([semver])]
param (
[Parameter(ValueFromPipeline)]
[semver]
$Version,

[Parameter(Mandatory)]
[ValidateSet('major', 'minor', 'patch')]
[string]
$BumpType,

[Parameter()]
[string]
$PreRelease = '',

[Parameter()]
[string]
$Build = ''
)

Process {

if ('major' -eq $BumpType) {
return [semver]::new($Version.Major + 1, 0, 0, $PreRelease, $Build)
}

if ('minor' -eq $BumpType) {
return [semver]::new($Version.Major, $Version.Minor + 1, 0, $PreRelease, $Build)
}

return [semver]::new($Version.Major, $Version.Minor, $Version.Patch + 1, $PreRelease, $Build)
}
}
63 changes: 0 additions & 63 deletions StepSemVer/functions/Step-SemVer.ps1

This file was deleted.

55 changes: 0 additions & 55 deletions StepSemVer/tests/StepSemVer.Tests.ps1

This file was deleted.

Loading

0 comments on commit 7a19277

Please sign in to comment.