Skip to content

Commit

Permalink
Move from Azure Pipelines to Github Actions +semver: none
Browse files Browse the repository at this point in the history
- Pinned version of Pester and PSScriptAnalyzer
- Updated Copyright statements.
  • Loading branch information
RobFaie authored and Rob McBot committed Jan 24, 2022
1 parent 2fca64f commit bd85df2
Show file tree
Hide file tree
Showing 30 changed files with 209 additions and 258 deletions.
173 changes: 173 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Main

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
PESTER_VERSION: '4.10.1'
PSSA_VERSION: '1.19.1'

defaults:
run:
shell: pwsh

jobs:
prep:
runs-on: 'ubuntu-20.04'

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
id: cache
with:
path: |
.modules
key: ${{ env.PSSA_VERSION }}-${{ env.PESTER_VERSION }}

- name: Install Modules
if: steps.cache.outputs.cache-hit != 'true'
run: |
$modules = '[
{ "Name": "PSScriptAnalyzer", "Version": "${{ env.PSSA_VERSION }}" },
{ "Name": "Pester", "Version": "${{ env.PESTER_VERSION }}" }
]' | ConvertFrom-Json
$modPath = '.modules'
if (-not (Test-Path -Path $modPath)) {
$null = New-Item -Path $modPath -ItemType Director
}
foreach ($module in $modules) {
$null = Save-Module -Name $module.Name -RequiredVersion $module.Version -Repository 'PSGallery' -Path $modPath -Confirm:$false -ErrorAction 'Stop'
}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: PwshZendesk
path: '**/*'

test:
needs: prep
runs-on: ${{ matrix.os }}
if: false
strategy:
matrix:
os: [ macos-11, ubuntu-20.04, windows-2019, windows-2022 ]

steps:
- name: Download Artifacts
uses: actions/download-artifact@v2

- name: PSScriptAnalyzer
run: |
$pssa = Import-Module -Name "$pwd/PwshZendesk/.modules/PSScriptAnalyzer/${{ env.PSSA_VERSION }}/PSScriptAnalyzer.psd1" -Passthru
Get-ChildItem -Directory | Invoke-ScriptAnalyzer | Format-Table -AutoSize
- name: Pester summary
id: pester
run: |
$pester = Import-Module -Name "$pwd/PwshZendesk/.modules/Pester/${{ env.PESTER_VERSION }}/Pester.psd1" -PassThru
Invoke-Pester -EnableExit -Show Fails
- name: Pester - Windows Powershell
if: runner.os == 'Windows'
shell: powershell
run: |
$pssa = Import-Module -Name "$pwd/PwshZendesk/.modules/PSScriptAnalyzer/${{ env.PSSA_VERSION }}/PSScriptAnalyzer.psd1" -Passthru
Get-ChildItem -Directory | Invoke-ScriptAnalyzer | Format-Table -AutoSize
- name: Pester - Windows Powershell
if: runner.os == 'Windows'
shell: powershell
run: |
$pester = Import-Module -Name "$pwd/PwshZendesk/.modules/Pester/${{ env.PESTER_VERSION }}/Pester.psd1" -PassThru
Invoke-Pester -EnableExit -Show Summary
release:
# needs: test
runs-on: 'ubuntu-20.04'
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: GitVersion
uses: gittools/actions/gitversion/[email protected]
id: gitversion
with:
useConfigFile: true

- name: Update Module Manifest
run: |
$manifest = Get-Content -Path ./PwshZendesk.psd1
$manifest = $manifest | ForEach-Object {
$_ -replace "(?<=ModuleVersion\s+=\s+('|`"))[^'`"]+(?=('|`"))", '${{ steps.gitversion.outputs.semVer }}'
}
$manifest | Set-Content -Path ./PwshZendesk.psd1
- name: Commit updated Module Manifest
run: |
git add ./PwshZendesk.psd1
git config user.email "[email protected]"
git config user.name "Rob McBot"
git commit --amend --no-edit
git push --force
git tag ${{ steps.gitversion.outputs.semVer }}
git push --tags --force
- run: zip -r PwshZendesk.zip . -x .\*/\* -x .\*
shell: bash

# - name: Create Release
# uses: actions/create-release@v1
# id: create_release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ steps.gitversion.outputs.semVer }}
# release_name: Release ${{ steps.gitversion.outputs.semVer }}
# draft: false
# prerelease: false

# - name: Upload Release Asset
# id: upload-release-asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: PwshZendesk.zip
# asset_name: PwshZendesk.zip
# asset_content_type: application/zip

- name: Publish Module
run: |
$cred = [PSCredential]::new('RobFaie', ('${{ secrets.GITHUB_TOKEN }}' | ConvertTo-SecureString -AsPlainText -Force))
$registerParams = @{
Name = 'Github'
SourceLocation = 'https://nuget.pkg.github.com/RobFaie/index.json'
PublishLocation = 'https://nuget.pkg.github.com/RobFaie/index.json'
Credential = $cred
}
Register-PSRepository @registerParams
Publish-Module -Path '.' -Repository 'Github' -Credential $cred -NuGetApiKey '${{ secrets.GITHUB_TOKEN }}'
2 changes: 2 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode: Mainline
no-bump-message: '\[skip ci\]|\+semver:\s?(none|skip)'
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 Telstra Purple Pty. Ltd.
Copyright (c) 2022 Robert W. McLeod

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 6 additions & 9 deletions PwshZendesk.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
# Generated on: 15/9/19
#
@{

# Script module or binary module file associated with this manifest.
RootModule = '.\PwshZendesk.psm1'

# Version number of this module.
ModuleVersion = '0.7.6'
ModuleVersion = '0.7.7'

# Supported PSEditions
CompatiblePSEditions = @(
Expand All @@ -23,13 +22,13 @@
GUID = 'fd14fe05-21fb-4dfb-969b-7012632b461e'

# Author of this module
Author = 'Telstra Purple DevSecOps'
Author = 'Robert McLeod'

# Company or vendor of this module
CompanyName = 'Telstra Purple Pty Ltd'
CompanyName = 'Insprear'

# Copyright statement for this module
Copyright = '(c) 2019 Telstra Purple Pty Ltd. All rights reserved.'
Copyright = '(c) 2019 Telstra Purple Pty. Ltd. (c) 2022 Robert W. McLeod'

# Description of the functionality provided by this module
Description = 'Wrapper for the Zendesk Rest API'
Expand Down Expand Up @@ -190,10 +189,10 @@
)

# A URL to the license for this module.
# LicenseUri = ''
LicenseUri = 'https://github.com/RobFaie/PwshZendesk/blob/main/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/Readify/PwshZendesk'
ProjectUri = 'https://github.com/RobFaie/PwshZendesk'

# A URL to an icon representing this module.
# IconUri = ''
Expand All @@ -219,6 +218,4 @@

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
DefaultCommandPrefix = 'Zendesk'

}

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PwshZendesk

![Build Status]
[![Main Badge Image]][Main Badge Link]

PwshZendesk is a Zendesk Support API client for Powershell.
PwshZendesk supports Powershell versions 5.1, 6, and 7 on all platforms.
Expand Down Expand Up @@ -58,7 +58,7 @@ PwshZendesk uses Style and Best Practice testing provided by [PSScriptAnalyzer]
Ensure you have [PSScriptAnalyzer] installed:

```Powershell
Install-Module -Name 'PSScriptAnalyzer'
Install-Module -Name 'PSScriptAnalyzer' -RequiredVersion '1.19.1'
```

And just run it over the `functions`, `internal`, and `tests` directories. The `PSScriptAnalyzerSettings.psd1` will get picked up and run all configured tests.
Expand All @@ -73,7 +73,7 @@ Get-ChildItem -Directory | Invoke-ScriptAnalyzer | Format-Table -AutoSize
Ensure you have [Pester] installed:

```Powershell
Install-Module -Name 'Pester'
Install-Module -Name 'Pester' -RequiredVersion '4.10.1'
```

And just run it from the project root in a non-interactive session.
Expand Down Expand Up @@ -134,4 +134,5 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
[httpstat.us]: https://httpstat.us
[SemVer]: http://semver.org/

[Build Status]: https://dev.azure.com/readify/Technology/_apis/build/status/Readify.PwshZendesk?branchName=master
[Main Badge Link]: https://github.com/RobFaie/PwshZendesk/actions/workflows/main.yml
[Main Badge Image]: https://github.com/RobFaie/PwshZendesk/actions/workflows/main.yml/badge.svg
Loading

0 comments on commit bd85df2

Please sign in to comment.