-
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.
refactor: use submodules (#11) +semver: minor
* refactor: rename step function * refactor: turn step function into submodule * feat: add bump type function * ci(renovate): pin digest and recommended * ci: move tests launcher to build * ci: pwsh continuous deployment * ci: remove codacy * ci: increase coverage target * ci: don't run tests twice * docs: fix renamed and added commands * refactor: rename repository * refactor: rename powershell module
- Loading branch information
Showing
20 changed files
with
338 additions
and
205 deletions.
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,7 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
|
||
[*.{ps1,psd1,psm1}] | ||
indent_size = 2 |
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,36 +1,44 @@ | ||
= StepSemVer | ||
|
||
StepSemVer is a pwsh module used to increment semantic versions number. | ||
|
||
https://www.powershellgallery.com/packages/StepSemVer[image:https://img.shields.io/powershellgallery/v/StepSemVer?style=for-the-badge[PowerShell Gallery]] https://www.powershellgallery.com/packages/StepSemVer[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. | ||
= ArwynFr.SemanticVersion | ||
|
||
A powershell module used to increment semantic version numbers. | ||
|
||
https://www.powershellgallery.com/packages/ArwynFr.SemanticVersion[image:https://img.shields.io/powershellgallery/v/ArwynFr.SemanticVersion?style=for-the-badge[PowerShell Gallery]] https://www.powershellgallery.com/packages/ArwynFr.SemanticVersion[image:https://img.shields.io/powershellgallery/dt/ArwynFr.SemanticVersion?style=for-the-badge[PowerShell Gallery]] link:/LICENSE[image:https://img.shields.io/github/license/ArwynFr/pwsh-SemanticVersion?style=for-the-badge[GitHub License]] | ||
|
||
You can download and install this powershell module from PSGallery: | ||
|
||
```Powershell | ||
Install-Module ArwynFr.SemanticVersion | ||
``` | ||
|
||
== ConvertTo-SemanticVersionBump | ||
|
||
This function returns `major`, `minor` or `patch` depending on the presence of a `+semver: major` or `+semver: minor` tag in the commit message. It is intended to be used with `Step-SemanticVersion`. | ||
|
||
```Powershell | ||
ConvertTo-SemanticVersionBump | ||
[[-CommitMessage] <string>] | ||
[<CommonParameters>] | ||
``` | ||
|
||
`-CommitMessage`:: *Required* and *Pipelinable*. A commit message string that the command will use as an input. | ||
|
||
== Step-SemanticVersion | ||
|
||
Returns an incremented semantic version number. | ||
|
||
```Powershell | ||
Step-SemanticVersion | ||
[[-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. |
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,8 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:recommended", | ||
"docker:pinDigests", | ||
":disableDependencyDashboard" | ||
] | ||
} |
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,15 +1,20 @@ | ||
name: continuous deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
deployment: | ||
uses: ArwynFr/ArwynFr/.github/workflows/pwsh-deployment.yaml@main | ||
with: | ||
manifest: ./StepSemVer/StepSemVer.psd1 | ||
source: ./StepSemVer/ | ||
secrets: | ||
PSGALLERY_APIKEY: ${{ secrets.PSGALLERY_APIKEY }} | ||
name: deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
deployment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source files | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run continuous deployment | ||
shell: pwsh | ||
run: ./build/Start-Deployment.ps1 -Verbose | ||
env: | ||
PSGALLERY_APIKEY: ${{ secrets.PSGALLERY_APIKEY }} | ||
GH_TOKEN: ${{ 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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
name: continuous integration | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [main] | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
integration: | ||
uses: ArwynFr/ArwynFr/.github/workflows/pwsh-integration.yaml@main | ||
with: | ||
tests: ./tests/Start-Tests.ps1 | ||
secrets: | ||
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
name: integration | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
integration: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source files | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run tests | ||
shell: pwsh | ||
run: ./build/Start-Tests.ps1 -Verbose |
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 @@ | ||
{} |
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,25 @@ | ||
@{ | ||
Author = 'ArwynFr' | ||
CompanyName = 'www.arwyn.fr' | ||
Copyright = '(c) 2019-2023 - ArwynFr - MIT license' | ||
|
||
ModuleVersion = '0.1.0' | ||
GUID = 'b4209e98-7072-45f3-bb89-ce520a182558' | ||
Description = 'A powershell module used to increment semantic version numbers' | ||
HelpInfoURI = 'https://github.com/ArwynFr/pwsh-SemanticVersion#readme' | ||
|
||
PrivateData = @{ | ||
ProjectUri = 'https://github.com/ArwynFr/pwsh-SemanticVersion' | ||
LicenseUri = 'https://github.com/ArwynFr/pwsh-SemanticVersion/blob/main/LICENSE' | ||
} | ||
|
||
NestedModules = @( | ||
'ConvertTo-SemanticVersionStep/ConvertTo-SemanticVersionStep.psd1' | ||
'Step-SemanticVersion/Step-SemanticVersion.psd1' | ||
) | ||
|
||
FunctionsToExport = @( | ||
'ConvertTo-SemanticVersionStep' | ||
'Step-SemanticVersion' | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
ArwynFr.SemanticVersion/ConvertTo-SemanticVersionStep/ConvertTo-SemanticVersionStep.psd1
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,5 @@ | ||
@{ | ||
ModuleVersion = '0.1.0' | ||
RootModule = 'ConvertTo-SemanticVersionStep.psm1' | ||
FunctionsToExport = @( 'ConvertTo-SemanticVersionStep' ) | ||
} |
17 changes: 17 additions & 0 deletions
17
ArwynFr.SemanticVersion/ConvertTo-SemanticVersionStep/ConvertTo-SemanticVersionStep.psm1
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,17 @@ | ||
function ConvertTo-SemanticVersionStep { | ||
[CmdletBinding()] | ||
[OutputType([string])] | ||
param ( | ||
[Parameter(Mandatory, ValueFromPipeline)] | ||
[string] | ||
$CommitMessage | ||
) | ||
|
||
Process { | ||
switch -Wildcard ($CommitMessage) { | ||
'*+semver: major*' { 'major' } | ||
'*+semver: minor*' { 'minor' } | ||
Default { 'patch' } | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
ArwynFr.SemanticVersion/Step-SemanticVersion/Step-SemanticVersion.psd1
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,5 @@ | ||
@{ | ||
ModuleVersion = '0.1.0' | ||
RootModule = 'Step-SemanticVersion.psm1' | ||
FunctionsToExport = @( 'Step-SemanticVersion' ) | ||
} |
68 changes: 34 additions & 34 deletions
68
StepSemVer/StepSemVer.psm1 → ...SemanticVersion/Step-SemanticVersion.psm1
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,35 +1,35 @@ | ||
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) | ||
} | ||
function Step-SemanticVersion { | ||
[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) | ||
} | ||
} |
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,21 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Arwyn | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
MIT License | ||
Copyright (c) 2019 ArwynFr | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
[CmdletBinding(SupportsShouldProcess)] | ||
param () | ||
|
||
|
||
$RootPath = Join-Path $PSScriptRoot .. | Convert-Path | ||
$ModulePath = Join-Path $RootPath ArwynFr.SemanticVersion | ||
|
||
Import-Module $ModulePath -Force | ||
$CurrentVersion = (gh release view --json tagName | ConvertFrom-Json).tagName | ||
$CommitMessage = [string] (git log -1 --pretty=%B) | ||
$Increment = $CommitMessage | ConvertTo-SemanticVersionStep | ||
$TargetVersion = $CurrentVersion | Step-SemanticVersion -BumpType $Increment -PreRelease $PreRelease | ||
|
||
"Increment = $Increment" | Write-Verbose | ||
"CurrentVersion = $CurrentVersion" | Write-Verbose | ||
"TargetVersion = $TargetVersion" | Write-Verbose | ||
|
||
Get-ChildItem $ModulePath -Recurse -Filter *.psd1 | ForEach-Object { | ||
Update-ModuleManifest -ModuleVersion $TargetVersion -Path $_ -WhatIf:$WhatIfPreference | ||
} | ||
|
||
Publish-Module -Path $ModulePath -NuGetApiKey $env:PSGALLERY_APIKEY -WhatIf:$WhatIfPreference | ||
|
||
if ($PSCmdlet.ShouldProcess($TargetVersion, 'gh release create')) { | ||
gh release create $TargetVersion --generate-notes | ||
git tag --force "v$($TargetVersion.Major).$($TargetVersion.Minor)" | ||
git tag --force "v$($TargetVersion.Major)" | ||
git push origin --tags --force | ||
} |
Oops, something went wrong.