This commit is contained in:
Bernie White 2023-02-27 18:53:13 +10:00 коммит произвёл GitHub
Родитель 1570d7788f
Коммит df60b7a7d9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 196 добавлений и 67 удалений

5
.github/workflows/build.yaml поставляемый
Просмотреть файл

@ -7,14 +7,12 @@ on:
branches: [main, 'release/*']
jobs:
test:
name: 'Tests'
name: Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
@ -56,7 +54,6 @@ jobs:
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3

1
.github/workflows/dependencies.yaml поставляемый
Просмотреть файл

@ -23,7 +23,6 @@ jobs:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:

58
.github/workflows/release.yaml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,58 @@
#
# Automated updates for release branches
#
# NOTES:
# This automatically bumps release branches to the latest stable tag.
name: Release
on:
release:
types:
- created
- deleted
workflow_dispatch:
inputs:
major:
type: choice
description: Determines the release branch to bump.
required: true
options:
- 'v1'
- 'v2'
default: v2
env:
RELEASE_BRANCH: ${{ inputs.major | 'v2' }}
LATEST_BRANCH: v2
permissions:
contents: read
jobs:
branch:
name: Update release branch
runs-on: ubuntu-latest
if: github.repository == 'microsoft/ps-rule'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure
run: |
git config user.name github-actions
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Push release branch
run: |
Import-Module ./scripts/branches.psm1;
$latest = '${{ env.RELEASE_BRANCH }}' -eq '${{ env.LATEST_BRANCH }}';
Update-Branch -Remote origin -Major ${{ env.RELEASE_BRANCH }} -Latest:$latest;
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.github/workflows/stale.yaml поставляемый
Просмотреть файл

@ -19,7 +19,6 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v7
with:
stale-issue-message: >

Просмотреть файл

@ -12,6 +12,20 @@ To learn about PSRule and how to write your own rules see [Getting started][1].
To get the latest stable release use:
```yaml
- name: Run PSRule analysis
uses: microsoft/ps-rule@latest
```
To get the latest stable release by major version use:
```yaml
- name: Run PSRule analysis
uses: microsoft/ps-rule@v2
```
To get a specific release use:
```yaml
- name: Run PSRule analysis
uses: microsoft/ps-rule@v2.7.0

Просмотреть файл

@ -6,6 +6,12 @@ See [upgrade notes][upgrade-notes] for helpful information when upgrading from p
## Unreleased
What's changed since v2.8.0:
- General improvements:
- Added support for action release branches by @BernieWhite.
[#214](https://github.com/microsoft/ps-rule/issues/214)
## v2.7.0
What's changed since v2.6.0:

56
scripts/branches.psm1 Normal file
Просмотреть файл

@ -0,0 +1,56 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Note:
# Handles bump to release branches.
function Update-Branch {
[CmdletBinding()]
[OutputType([void])]
param (
[Parameter(Mandatory = $True)]
[String]$Major,
[Parameter(Mandatory = $True)]
[String]$Remote,
[Parameter(Mandatory = $False)]
[Switch]$Latest
)
process {
$latest = Get-LatestVersion -Remote $Remote -Major $Major;
Write-Host "Latest stable release is: $latest";
Write-Host "Checking out tag for: $latest"
git fetch --tags $Remote;
git checkout refs/tags/v$latest;
Write-Host "Updating release branch: $Major";
git push $Remote refs/tags/v$latest`:refs/heads/$Major --force;
if ($Latest) {
Write-Host "Updating latest to: $Major";
git push $Remote refs/tags/v$latest`:refs/heads/latest --force;
}
git checkout main;
}
}
function Get-LatestVersion {
[CmdletBinding()]
[OutputType([String])]
param (
[Parameter(Mandatory = $True)]
[String]$Major,
[Parameter(Mandatory = $True)]
[String]$Remote
)
process {
return (gh api repos/microsoft/ps-rule/releases | Out-String | ConvertFrom-Json | Where-Object {
$_.prerelease -eq $False -and $_.name -like "$Major.*"
} | Select-Object -Property @{ Name = 'version'; Expression = { [System.Version]::Parse($_.name.Replace('v', '')) } } | Sort-Object -Property version -Descending -Top 1).Version.ToString();
}
}