Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromirk committed Jan 12, 2024
2 parents bb6120a + bfeab65 commit 0d618ba
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 249 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/create-prerelase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
paths:
- 'Scripts/**'
- 'Tools/**'
branches: [ dev ]

jobs:
Expand All @@ -16,22 +17,28 @@ jobs:
if: "!contains(github.event.head_commit.message, '[no release]')"
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
- name: Build scripts
id: build
shell: powershell
run: |
./build.ps1 -Version prerelease
./build.ps1 -Version dev
$filename = "mslab_dev-$((Get-Date -Format "yyyyMMdd")).zip"
mv ./Release.zip $filename
echo "::set-output name=filename::$filename"
- uses: "marvinpinto/action-automatic-releases@latest"
echo "filename=$filename" >> $env:GITHUB_OUTPUT
- name: Delete current dev prerelease
uses: cb80/delrel@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "dev"
tag: dev
- name: Create new dev prerelease
uses: softprops/action-gh-release@v1
with:
tag_name: dev
name: dev branch preview
generate_release_notes: true
prerelease: true
title: "dev branch preview"
files: |
${{ steps.build.outputs.filename }}
Output/Tools/*.ps1
94 changes: 46 additions & 48 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ on:
push:
paths:
- 'Scripts/**'
- 'Tools/**'
branches: [ master ]

jobs:
new-version:
environment: release
name: Bump version
if: "!contains(github.event.head_commit.message, '[no release]')"
runs-on: windows-2019
outputs:
previous_tag: ${{ steps.bump.outputs.previous_tag }}
new_tag: ${{ steps.bump.outputs.new_tag }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- id: bump
name: Bump version
run: |
$today = Get-Date
$newVersion = @($today.ToString("yy"), $today.ToString("MM"), "1")
git fetch --tags
$hash = git rev-list --tags --topo-order --max-count=1
# Get the latest tag that matches our versioning schema (starts with letter v)
$hash = git rev-list --tags=v* --topo-order --max-count=1
if($hash) {
$currentTag = git describe --tags $hash
$parts = $currentTag.Substring(1) -split '\.'
Expand All @@ -35,72 +38,67 @@ jobs:
$newTag = "v" + ($newVersion -join ".")
git tag $newTag
if(-not $?) {
throw "Tagging of new release version failed!"
}
git push origin $newTag
"New version: $newTag"
echo "::set-output name=previous_tag::$currentTag"
echo "::set-output name=new_tag::$newTag"
- name: Push version tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true
echo "previous_tag=$currentTag" >> $env:GITHUB_OUTPUT
echo "new_tag=$newTag" >> $env:GITHUB_OUTPUT
new-release:
name: Create release
if: "!contains(github.event.head_commit.message, '[no release]')"
runs-on: windows-2019
runs-on: self-hosted
needs: new-version
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: "Build scripts"
uses: azure/powershell@v1
- name: Build and sign release scripts
shell: pwsh
env:
SIGN_SCRIPT_URI: ${{ secrets.SIGN_SCRIPT_URI }}
CLIENT_ID: ${{ secrets.CLIENT_ID }} # just to ofusctate it in the output
with:
azPSVersion: "latest"
inlineScript: |
./build.ps1 -Version ${{ needs.new-version.outputs.new_tag }} -SignScripts $true -SignScriptUri $env:SIGN_SCRIPT_URI -ClientId $env:CLIENT_ID
CLIENT_ID: ${{ secrets.CLIENT_ID }} # just to obfusctate it in the output
run: |
./build.ps1 -Version ${{ needs.new-version.outputs.new_tag }} -SignScripts $true -SignScriptUri $env:SIGN_SCRIPT_URI -ClientId $env:CLIENT_ID
Move-Item ./Release.zip mslab_${{ needs.new-version.outputs.new_tag }}.zip
- name: Create changelog
id: changelog
shell: powershell
run: |
if("${{ needs.new-version.outputs.previous_tag }}" -ne "") {
$changelog = (& { git log ${{ needs.new-version.outputs.previous_tag }}..HEAD --pretty=format:'- %s (%h)' --abbrev-commit -- Scripts }) -join '%0D%0A'
$changelog = (& { git log ${{ needs.new-version.outputs.previous_tag }}..HEAD --pretty=format:'- %s (%h)' --abbrev-commit -- Scripts Tools }) -join "`n"
"Changes for ${{ needs.new-version.outputs.previous_tag }} are:"
$changelog
} else {
$changelog = ""
}
echo "::set-output name=changelog::$changelog"
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.new-version.outputs.new_tag }} # ${{ github.ref }}
release_name: Release ${{ needs.new-version.outputs.new_tag }} # ${{ github.ref }}
body: |
Changes in this version:
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
$changeLogContent = @"
:package: MSLab scripts are in **[mslab_${{ needs.new-version.outputs.new_tag }}.zip](${{ github.server_url }}/${{ github.repository }}/releases/download/${{ needs.new-version.outputs.new_tag }}/mslab_${{ needs.new-version.outputs.new_tag }}.zip)** file.
:information_source: Remaining `.ps1` files in this release would be downloaded on-demand by MSLab scripts during deployment, only if needed.
- name: Upload ZIP to Release
id: upload-scripts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
"@
if($changelog -ne "") {
$changeLogContent += @"
## Changes in this version
$changelog
"@
}
Set-Content -Value $changeLogContent -Path .\changelog.md
- name: Create new release
uses: softprops/action-gh-release@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Release.zip
asset_name: mslab_${{ needs.new-version.outputs.new_tag }}.zip
asset_content_type: application/zip
tag_name: ${{ needs.new-version.outputs.new_tag }} # ${{ github.ref }}
name: MSLab ${{ needs.new-version.outputs.new_tag }} # ${{ github.ref }}
generate_release_notes: false
body_path: changelog.md
files: |
mslab_${{ needs.new-version.outputs.new_tag }}.zip
Output/Tools/*.ps1
6 changes: 3 additions & 3 deletions Scripts/0_Shared.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function Get-PcSystemType {

$aiPropertyCache = @{}

function New-TelemetryEvent {
function Initialize-TelemetryEvent {
param(
[Parameter(Mandatory = $true)]
[string]$Event,
Expand Down Expand Up @@ -303,12 +303,12 @@ function Send-TelemetryEvent {
)

process {
$telemetryEvent = New-TelemetryEvent -Event $Event -Properties $Properties -Metrics $Metrics -NickName $NickName
$telemetryEvent = Initialize-TelemetryEvent -Event $Event -Properties $Properties -Metrics $Metrics -NickName $NickName
Send-TelemetryObject -Data $telemetryEvent
}
}

function Send-TelemetryEvents {
function Send-TelemetryEvent {
param(
[Parameter(Mandatory = $true)]
[array]$Events
Expand Down
Loading

0 comments on commit 0d618ba

Please sign in to comment.