Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Auto-Publish to Powershell Gallery #54

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Create GitHub release and publish to the PowerShell Gallery"

on:
push:
branches:
- master
workflow_dispatch:

env:
PSProjectName: bConnect

jobs:
job-main:
name: main
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0

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

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

- name: Install codaamok.build and dependent modules, and set environment variables
run: |
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Install-Module "InvokeBuild" -Force
$Username, $ProjectName = $env:GITHUB_REPOSITORY -split "/"
Invoke-Build -ModuleName $env:PSProjectName -Author $Username -Task "InstallDependencies","ImportBuildModule","SetGitHubActionEnvironmentVariables"
shell: pwsh

- name: Build
run: Invoke-Build -ModuleName $env:PSProjectName -Author $env:GH_USERNAME -Version $env:GitVersion_SemVer -NewRelease $true
shell: pwsh

- name: Publish to PowerShell Gallery
run: Invoke-Build -ModuleName $env:PSProjectName -Task "PublishModule"
shell: pwsh
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.GitVersion_SemVer }}
release_name: v${{ env.GitVersion_SemVer }}
body_path: release/releasenotes.txt
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: release/${{ env.PSProjectName }}_${{ env.GitVersion_SemVer }}.zip
asset_name: ${{ env.PSProjectName }}_${{ env.GitVersion_SemVer }}.zip
asset_content_type: application/zip

- name: Commit CHANGELOG.md and module manifest
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add CHANGELOG.md ${{ env.PSProjectName }}/${GH_PROJECTNAME}.psd1 docs
git commit -m "Released ${{ env.GitVersion_SemVer }}"

- name: Push commit
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/publish-to-gallery.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/*
release/*
!*.gitkeep
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Added about help
- Added Build-Workflow
- Added Changelog File

### Changed
- Moved Scriptblock from bConnect.psm1 to Initialize-bConnect.ps1

25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Contributing

Kindly adhere to the principles detailed in this document while contributing.

This project leverages [GitVersion](https://gitversion.net) and tries to adhere to [SemVer](https://semver.org/).

## Issues

### Bug reports

Raise issues and bug reports with regards to this product in the Issues tab of this project.

### Fixing an issue

If you're interested in fixing an issue in this project, firstly, thank you!

1. Fork the repository and create a branch off of `main`/`master`
1. If you're creating a new feature, name your branch `feature/<InsertAppropriateDescriptionHere>`. If you're fixing a bug, name your branch `fix/<InsertAppropriateDescriptionHere>`.
2. Write your code
3. Update CHANGELOG.md with your changes (preferably using the [ChangeLogManagement](https://www.powershellgallery.com/packages/ChangelogManagement) PowerShell module for formatting consistency)
```powershell
Add-ChangelogData -Type Added -Data "Added CONTRIBUTING.md"`
```
4. For good measure, check for any changes to the upstream repo
5. Make sure you have pushed your commits to your new branch and then create a pull request
8 changes: 8 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mode: Mainline
no-bump-message: '\+semver:\s?(none|skip)|^Released\s\d\.\d\.\d$'
branches:
hotfix:
regex: ^(hot)?fix(es)?[/-]
ignore:
sha: []
merge-message-formats: {}
20 changes: 20 additions & 0 deletions bConnect/Public/Initialize-bConnect.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ Function Initialize-bConnect() {
[switch]$AcceptSelfSignedCertificate
)

# fallback bConnect version
$script:_bConnectFallbackVersion = "v1.0"

# overwrite Invoke-RestMethod timeout
$script:_ConnectionTimeout = 0

# Only to ignore certificates errors (self-signed)
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;

public class ignoreCertificatePolicy : ICertificatePolicy {
public ignoreCertificatePolicy() {}
public bool CheckValidationResult(ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb) { return true; }
}
"@

# init the connection (uri and credentials)
$script:_connectInitialized = $false

If($AcceptSelfSignedCertificate) {
[System.Net.ServicePointManager]::CertificatePolicy = New-Object ignoreCertificatePolicy
}
Expand Down
27 changes: 0 additions & 27 deletions bConnect/bConnect.ps1

This file was deleted.

Binary file modified bConnect/bConnect.psd1
Binary file not shown.
20 changes: 0 additions & 20 deletions bConnect/bConnect.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@
# Please place your comments, questions, improvements, etc
# on Github: https://github.com/baramundisoftware/PS-bConnect

# fallback bConnect version
$script:_bConnectFallbackVersion = "v1.0"

# overwrite Invoke-RestMethod timeout
$script:_ConnectionTimeout = 0

# Only to ignore certificates errors (self-signed)
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;

public class ignoreCertificatePolicy : ICertificatePolicy {
public ignoreCertificatePolicy() {}
public bool CheckValidationResult(ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb) { return true; }
}
"@

# init the connection (uri and credentials)
$script:_connectInitialized = $false

# Load all scripts of the module
foreach($modfile in (Get-ChildItem *.ps1 -Path "$PSScriptRoot\Private")){
. $modfile.FullName
Expand Down
16 changes: 16 additions & 0 deletions bConnect/en-US/about_bConnect.help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TOPIC
about_bConnect

SHORT DESCRIPTION
Powershell module for accessing the REST-API of the baramundi Management Suite.

LONG DESCRIPTION
Powershell module for accessing the REST-API of the baramundi Management Suite.

To learn how to use any of the functions, it is recommended you make use of
the command: `Get-Help <functionName>`. For example,
`Get-Help Initialize-bConnect` will show you how to use the Initialize-bConnect
function.

AUTHENTICATION
Bevor runing any function of bConnect you have to run `Initialize-bConnect`
Loading