Skip to content

Create LICENSE

Create LICENSE #42

Workflow file for this run

name: Press Build
on:
push:
branches:
- master
- main
- ci
- production
tags:
- '*'
release:
types:
- published
pull_request:
branches:
- master
- main
- production
jobs:
build:
name: πŸ‘· Build
runs-on: ubuntu-20.04
steps:
# Workaround: https://github.com/actions/runner/issues/520#issuecomment-720508121
- if: always()
name: πŸ› Get Debug Status
id: debugStatus
run: |
echo '::set-output name=runnerDebug::${{secrets.ACTIONS_RUNNER_DEBUG}}'
echo '::set-output name=stepDebug::${{secrets.ACTIONS_STEP_DEBUG}}'
- name: 🚚 Checkout
uses: actions/checkout@v2
with:
# Required for GitVersion
#TODO: Calculate fetch depth up to the parent branch's last version tag (this is all gitversion really needs)
fetch-depth: 0
- name: πŸ”— Cache Powershell Modules
uses: actions/cache@v2
with:
path: |
~/Documents/Powershell/Modules
~/Documents/WindowsPowershell/Modules
~/.local/share/powershell/Modules
~/.local/share/Press
~/AppData/Local/Press
~/.nuget/packages/gitversion.tool
key: build-${{ hashFiles('.config/RequiredModules.psd1') }}
- if: steps.debugStatus.outputs.stepDebug
name: πŸ”¬ Powershell Environment Information
shell: pwsh
run: |
"::group::Powershell Modules"
($ENV:PSModulePath).split([io.path]::pathseparator) | where {Test-Path $_} | Get-ChildItem
"::endgroup"
"::group::Variables"
Get-Variable | select name,value | Out-String
"::endgroup"
"::group::Environment"
dir env: | Out-String
"::endgroup"
- name: πŸ‘· Build
id: build
shell: pwsh
run: |
if ('${{secrets.ACTIONS_STEP_DEBUG}}') {$verbosePreference = 'continue'}
./build '.,Package'
- name: πŸ“¦ Capture Powershell Module
uses: actions/upload-artifact@v2
with:
name: PSModule
path: BuildOutput/${{ steps.build.outputs.moduleName }}
- name: πŸ“¦ Capture Powershell Zip
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build.outputs.moduleName }}-${{ steps.build.outputs.nugetVersion }}.zip
#FIXME: Double zip
path: BuildOutput/*.zip
- name: πŸ“¦ Capture Powershell Nuget Package
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build.outputs.moduleName }}.${{ steps.build.outputs.nugetVersion }}.nupkg
path: BuildOutput/*.nupkg
- if: always() && runner.os != 'Windows' && steps.debugStatus.outputs.runnerDebug
name: πŸ› Debug via SSH if ACTIONS_RUNNER_DEBUG secret is set
uses: lhotari/action-upterm@v1
#TODO: Move to dedicated function
- name: πŸ“¦ Update Draft Github Release
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/ci'
shell: pwsh
run: |
./build 'Press.UpdateGitHubRelease'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
name: πŸ§ͺ Test
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
# - ubuntu-latest
- ubuntu-20.04
- ubuntu-18.04
# - ubuntu-16.04
# - windows-latest
- windows-2019
# - windows-2016
# - macos-latest
- macos-11.0
- macos-10.15
steps:
- name: 🚚 Checkout
uses: actions/checkout@v2
with:
# Required for GitVersion
#TODO: Calculate fetch depth up to the parent branch's last version tag (this is all gitversion really needs)
fetch-depth: 0
- name: πŸ”— Cache Powershell Modules
uses: actions/cache@v2
with:
path: |
~/Documents/Powershell/Modules
~/Documents/WindowsPowershell/Modules
~/.local/share/powershell/Modules
~/.local/share/Press
~/AppData/Local/Press
~/.nuget/packages/gitversion.tool
key: test-${{ matrix.os }}-${{ hashFiles('Source/.config/RequiredModules.psd1') }}
- name: βž• Restore Built Powershell Module
uses: actions/download-artifact@v2
with:
name: PSModule
#TODO: Pull this from environment setup
path: BuildOutput/${{ github.event.repository.name }}
- name: πŸ§ͺ Test Powershell 7+
shell: pwsh
run: |
if ('${{secrets.ACTIONS_STEP_DEBUG}}') {$verbosePreference = 'continue'}
#Press Meta
if ('${{ github.event.repository.name }}' -eq 'Press') {
$GLOBAL:PressModulePath = Resolve-Path ./BuildOutput/Press/Press.psd1
}
. ./build.ps1 'Test'
deployPrerelease:
name: πŸš€ Deploy Prelease Module
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
environment: Powershell Gallery PreRelease
needs:
- build
- test
steps:
- name: βž• Restore Built Powershell Module
uses: actions/download-artifact@v2
with:
name: PSModule
#TODO: Get BuildOutput Config Path
path: BuildOutput/${{ github.event.repository.name }}
- name: πŸš€ Publish Module to PowerShell Gallery
shell: pwsh
run: |
if (-not '${{ secrets.PS_GALLERY_KEY }}') {throw 'You need to configure a PS_GALLERY_KEY secret for this environment with your Powershell Gallery API Key'}
Install-Module Microsoft.Powershell.SecretManagement -RequiredVersion 1.1.0 -Force
Install-Module PSFramework -RequiredVersion 1.6.205 -Force -AllowClobber
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}
deploy:
name: πŸš€ Deploy
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
environment: Powershell Gallery
needs:
- build
- test
steps:
- name: βž• Restore Built Powershell Module
uses: actions/download-artifact@v2
with:
name: PSModule
#TODO: Get BuildOutput Config Path
path: BuildOutput/${{ github.event.repository.name }}
- name: πŸš€ Publish Module to PowerShell Gallery
shell: pwsh
run: |
if (-not '${{ secrets.PS_GALLERY_KEY }}') {throw 'You need to configure a PS_GALLERY_KEY secret for this environment with your Powershell Gallery API Key'}
Install-Module Microsoft.Powershell.SecretManagement -RequiredVersion 1.1.0 -Force
Install-Module PSFramework -RequiredVersion 1.6.205 -Force -AllowClobber
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}