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

New CI/CD using GH actions #60

Merged
merged 9 commits into from
Mar 10, 2024
Merged
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
58 changes: 0 additions & 58 deletions .azure-pipelines/CI.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .azure-pipelines/templates/test-powershell.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .azure-pipelines/templates/test-pwsh.yml

This file was deleted.

158 changes: 158 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
name: SteamPS CI/CD workflow
on:
push:
branches:
- main
- master

pull_request:
branches:
- main
- master

release:
types:
- published

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
POWERSHELL_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
BUILD_CONFIGURATION: ${{ fromJSON('["Debug", "Release"]')[startsWith(github.ref, 'refs/tags/v')] }}

jobs:
build:
name: 👷 Build
runs-on: windows-latest
steps:
- name: 🚚 Check out repository
uses: actions/checkout@v4

- name: 🐛 Build module - Debug
shell: pwsh
run: ./build.ps1 -Configuration $env:BUILD_CONFIGURATION -Task Build
if: ${{ env.BUILD_CONFIGURATION == 'Debug' }}

- name: 🚀 Build module - Publish
shell: pwsh
run: ./build.ps1 -Configuration $env:BUILD_CONFIGURATION -Task Build
if: ${{ env.BUILD_CONFIGURATION == 'Release' }}

- name: 📦 Capture PowerShell Module
uses: actions/upload-artifact@v4
with:
name: PSModule
path: output/*.nupkg

test:
name: 🧪 Test
needs:
- build
runs-on: ${{ matrix.info.os }}
strategy:
fail-fast: false
matrix:
info:
- name: 🪟 Win2019_PS-5.1
psversion: '5.1'
os: windows-2019
- name: 🪟 Win2019_PS-7
psversion: '7'
os: windows-2019
- name: 🪟 Win2022_PS-5.1
psversion: '5.1'
os: windows-latest
- name: 🪟 Win2022_PS-7
psversion: '7'
os: windows-latest

steps:
- name: 🚚 Checkout
uses: actions/checkout@v4

- name: ➕ Restore Built PowerShell Module
uses: actions/download-artifact@v4
with:
name: PSModule
path: output

- name: 📦 Install Built PowerShell Module
shell: pwsh
run: |
# Get the manifest from the newly built module.
$manifestItem = Get-Item ([IO.Path]::Combine('SteamPS', '*.psd1'))
$moduleName = $manifestItem.BaseName
$Manifest = Test-ModuleManifest -Path $manifestItem.FullName -ErrorAction SilentlyContinue -WarningAction Ignore

if ($env:BUILD_CONFIGURATION -eq 'Release') {
$Version = $env:GITHUB_REF -replace '^refs/tags/v(\d+\.\d+\.\d+)', '$1'
} else {
$Version = $Manifest.Version
}

$destPath = [IO.Path]::Combine('output', $moduleName, $Version)
if (-not (Test-Path -LiteralPath $destPath)) {
New-Item -Path $destPath -ItemType Directory | Out-Null
}

Get-ChildItem output/*.nupkg | Rename-Item -NewName { $_.Name -replace '.nupkg', '.zip' }

Expand-Archive -Path output/*.zip -DestinationPath $destPath -Force -ErrorAction Stop

- name: 🧪 Run Tests - Windows PowerShell
if: ${{ matrix.info.psversion == '5.1' }}
shell: powershell
run: ./build.ps1 -Configuration $env:BUILD_CONFIGURATION -Task Test

- name: 🧪 Run Tests - PowerShell
if: ${{ matrix.info.psversion != '5.1' }}
shell: pwsh
run: ./build.ps1 -Configuration $env:BUILD_CONFIGURATION -Task Test

- name: ⬆️ Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results (${{ matrix.info.name }})
path: ./output/TestResults/Pester.xml

- name: ⬆️ Upload Coverage Results
if: always() && !startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: Coverage Results (${{ matrix.info.name }})
path: ./output/TestResults/Coverage.xml

- name: ⬆️ Upload Coverage to codecov
if: always() && !startsWith(github.ref, 'refs/tags/v')
uses: codecov/codecov-action@v4
with:
files: ./output/TestResults/Coverage.json
flags: ${{ matrix.info.name }}
token: ${{ secrets.CODECOV_TOKEN }}

publish:
name: 🚀 Deploy
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build
- test
runs-on: windows-latest
steps:
- name: ➕ Restore Built PowerShell Module
uses: actions/download-artifact@v4
with:
name: PSModule
path: ./

- name: 🚀 Publish to Gallery
if: github.event_name == 'release'
shell: pwsh
run: >-
dotnet nuget push '*.nupkg'
--api-key $env:PSGALLERY_TOKEN
--source 'https://www.powershellgallery.com/api/v2/package'
--no-symbols
env:
PSGALLERY_TOKEN: ${{ secrets.PS_GALLERY_KEY }}
48 changes: 0 additions & 48 deletions .github/workflows/PSScriptAnalyzer.yml

This file was deleted.

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

[![AppVeyor master](https://img.shields.io/appveyor/ci/hjorslev/SteamPS/master?label=AppVeyor&logo=appveyor&style=flat)](https://ci.appveyor.com/project/hjorslev/steamps)
[![Azure DevOps builds](https://img.shields.io/azure-devops/build/fhjorslev/69d18b04-0023-433d-a649-bcf821875235/5?label=Azure+Pipelines&logo=azure-pipelines)](https://dev.azure.com/fhjorslev/SteamPS/_build/latest?definitionId=5&branchName=master)
[![AppVeyor tests (master)](https://img.shields.io/appveyor/tests/hjorslev/SteamPS/master?label=master&logo=appveyor&style=flat)](https://ci.appveyor.com/project/hjorslev/steamps/build/tests)
[![Codacy master grade](https://img.shields.io/codacy/grade/bf0bb30dfc904b2f885c4f0ccdf1ea78/master?label=master&style=flat)](https://app.codacy.com/manual/hjorslev/SteamPS/dashboard?bid=13716491)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/hjorslev/SteamPS/CI.yml?logo=GitHub&label=CI%2FCD)](https://github.com/hjorslev/SteamPS/actions/workflows/CI.yml)

- [SteamPS](#steamps)
- [Introduction](#introduction)
Expand All @@ -21,7 +18,7 @@
## Introduction

[![PowerShell Version](https://img.shields.io/powershellgallery/v/SteamPS.svg?style=flat&logo=PowerShell)](https://www.powershellgallery.com/packages/SteamPS)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/SteamPS?style=flat)](https://www.powershellgallery.com/packages/SteamPS)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/SteamPS?style=flat&logo=PowerShell)](https://www.powershellgallery.com/packages/SteamPS)

SteamPS is a [PowerShell module](https://github.com/PowerShell/PowerShell/) that
can interact with [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD),
Expand Down
9 changes: 0 additions & 9 deletions SteamPS.PSDeploy.ps1

This file was deleted.

Loading