diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03dfd35..7be5b96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,6 @@ on: push: branches: [ main ] paths-ignore: - - action.yml - README.md - LICENSE - CODEOWNERS diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 51358fe..7e37523 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,10 +19,11 @@ env: jobs: preflight: runs-on: ubuntu-latest + if: ${{ github.event.action != 'unpublished' && github.event.action != 'deleted' }} steps: - uses: actions/checkout@v2 - - uses: smokedlinq/powershell-devops@v0 + - uses: powershell-devops/install-module@v1 - name: Install pre-requisites run: Install-Module Pester -MinimumVersion 5.2.0 -Force @@ -43,7 +44,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: smokedlinq/powershell-devops@v0 + - uses: powershell-devops/install-module@v1 - name: Publish to PowerShellGallery run: ./.github/workflows/scripts/publish.ps1 @@ -63,7 +64,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: smokedlinq/powershell-devops@v0 + - uses: powershell-devops/install-module@v0 - name: Unlist from PowerShellGallery run: ./.github/workflows/scripts/unlist.ps1 \ No newline at end of file diff --git a/README.md b/README.md index eb0c77f..8ad9b5c 100644 --- a/README.md +++ b/README.md @@ -1,115 +1,10 @@ # powershell-devops -![CI](https://github.com/smokedlinq/powershell-devops/workflows/ci/badge.svg) +![CI](https://github.com/powershell-devops/powershell-devops/workflows/ci/badge.svg) [![PowerShellGallery](https://img.shields.io/powershellgallery/dt/powershell-devops.svg)](https://www.powershellgallery.com/packages/powershell-devops) PowerShell module for dealing with commands in Azure DevOps Pipelines and GitHub Workflows. ## GitHub Action -See [action.yml](action.yml) for detailed list of inputs. - -Basic: - -```yml -steps: -- uses: smokedlinq/powershell-devops@v0 -``` - -Specific version: - -```yml -steps: -- uses: smokedlinq/powershell-devops@v0 - with: - required-version: 0.0.7 -``` - -Minimum version: - -```yml -steps: -- uses: smokedlinq/powershell-devops@v0 - with: - minimum-version: 0.0.7 -``` - -Maximum version: - -```yml -steps: -- uses: smokedlinq/powershell-devops@v0 - with: - maximum-version: 0.0.7 -``` - -## Commands - -### Set-EnvironmentVariable - -Sets the environment variable for the current process and optionally marks it as a secret. - -```powershell -set-env MY_VALUE 'Hello World!' -``` - -*Note: `set-env` is an alias for `Set-EnvironmentVariable`.* - -### Get-EnvironmentVariable - -Gets the environment variable for the current process and optionally throws an error if it is not defined. - -```powershell -get-env MY_ENV_VALUE -Require -``` - -*Note: `get-env` is an alias for `Get-EnvironmentVariable`.* - -### Add-Path - -Prepends the value to the PATH environment. - -```powershell -Add-Path $PSScriptRoot -``` - -### Enter-Group / Exit-Group - -Creates an expandable group in the log. Anything you print to the log between the `Enter-Group` and `Exit-Group` commands is nested inside an expandable entry in the log. - -```powershell -Enter-Group 'My group' -try { - # .. some other commands ... -} finally { - Exit-Group -} -``` - -### Utility functions - -These functions are helper functions that are used by the module but could also be useful within your script. - -#### Test-AdoPipeline - -Returns true if running in an Azure DevOps Pipeline, determined by the environment variable `TF_BUILD` having a value. - -```powershell -Test-AdoPipeline -``` - -#### Test-GitHubWorkflow - -Returns true if running in a GitHub Workflow, determined by the environment variable `GITHUB_ACTIONS` having a value. - -```powershell -Test-GitHubWorkflow -``` - -## License - -The scripts and documentation in this project are released under the [MIT License](LICENSE) - -## Contributions - -Contributions are welcome! +See [action.yml](/powershell-devops/install-module/action.yml) for more information. diff --git a/action.yml b/action.yml deleted file mode 100644 index db58e19..0000000 --- a/action.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Install powershell-devops Module -description: Installs the powershell-devops module from the PowerShell Gallery -author: smokedlinq -branding: - icon: play - color: green -inputs: - required-version: - description: 'Optional required version to install. If not provided, will install the latest version. Example: 0.0.7' - required: false - minimum-version: - description: 'Optional minimum version to install. If not provided, will install the latest version. Example: 0.0.7' - required: false - maximum-version: - description: 'Optional maximum version to install. If not provided, will install the latest version. Example: 0.0.7' - required: false -runs: - using: composite - steps: - - name: Install-Module powershell-devops - shell: pwsh - env: - # https://github.com/actions/runner/issues/665 - INPUT_REQUIRED_VERSION: ${{ inputs.required-version }} - INPUT_MINIMUM_VERSION: ${{ inputs.minimum-version }} - INPUT_MAXIMUM_VERSION: ${{ inputs.maximum-version }} - run: | - if ($env:INPUT_REQUIRED_VERSION) { - Install-Module powershell-devops -RequiredVersion $env:INPUT_REQUIRED_VERSION -Force - } else { - $InstallModuleParameters = @{} - - if ($env:INPUT_MINIMUM_VERSION) { - $InstallModuleParameters.MinimumVersion = $env:INPUT_MINIMUM_VERSION - } - - if ($env:INPUT_MAXIMUM_VERSION) { - $InstallModuleParameters.MaximumVersion = $env:INPUT_MAXIMUM_VERSION - } - - Install-Module powershell-devops -Force -AllowClobber @InstallModuleParameters - } \ No newline at end of file diff --git a/powershell-devops.psd1 b/powershell-devops.psd1 index d0b0cd0..1605e96 100644 --- a/powershell-devops.psd1 +++ b/powershell-devops.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '0.3.0' + ModuleVersion = '1.0.1' RootModule = 'powershell-devops.psm1' GUID = 'c1bdd96a-5c69-43f7-8155-9cd5f5a6019d' Author = 'https://github.com/smokedlinq' @@ -25,4 +25,4 @@ ProjectUri = 'https://github.com/smokedlinq/powershell-devops' } } -} \ No newline at end of file +} diff --git a/powershell-devops.psm1 b/powershell-devops.psm1 index c113712..80e4a13 100644 --- a/powershell-devops.psm1 +++ b/powershell-devops.psm1 @@ -37,9 +37,8 @@ function Set-EnvironmentVariable { } if ($Output) { "$Name=$Value" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - } else { - "$Name=$Value" | Out-File -FilePath $env:GITHUB_ENV -Append } + "$Name=$Value" | Out-File -FilePath $env:GITHUB_ENV -Append } Set-Item -Path env:$Name -Value $Value -Force @@ -103,4 +102,4 @@ function Add-Path { } $env:PATH = "$Path;$env:PATH" -} \ No newline at end of file +}