Skip to content

Commit

Permalink
ci: update ci workflow for semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbutt committed Mar 6, 2024
1 parent 85a2aaa commit 9e226fd
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 36 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ jobs:
- name: Build
run: ./build.ps1

#- name: Archive
# run: pnpm genlinx archive --verbose

- name: Release
if: github.ref == 'refs/heads/master'
run: pnpm semantic-release
Expand Down
22 changes: 20 additions & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,24 @@
"npmPublish": false
}
],
[
"@semantic-release/exec",
{
"shell": "pwsh",
"prepareCmd": "(Get-Content -Path manifest.json) -replace '\"version\": \".*\"', '\"version\": \"${nextRelease.version}\"' | Set-Content manifest.json"
}
],
[
"@semantic-release/exec",
{
"shell": "pwsh",
"prepareCmd": "./archive.ps1"
}
],
[
"@semantic-release/git",
{
"assets": ["package.json", "CHANGELOG.md", "manifest.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}
],
Expand All @@ -105,10 +120,13 @@
{
"assets": [
{
"path": "./src/**/*.{tko,TKO}"
"path": "./**/*.{axi,AXI}"
},
{
"path": "./src/*.{tko,TKO}"
},
{
"path": "./*.archive.zip"
"path": "./dist/*.{zip,sha256}"
}
]
}
Expand Down
71 changes: 40 additions & 31 deletions SymLink.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env pwsh
#Requires -RunAsAdministrator

<#
Expand Down Expand Up @@ -35,62 +36,70 @@ SOFTWARE.

param (
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[string]
$Path = ".",
$ModulePath = "C:\Program Files (x86)\Common Files\AMXShare\Duet\module",

[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[string]
$ModulePath = "C:\Program Files (x86)\Common Files\AMXShare\Duet\module",
$IncludePath = "C:\Program Files (x86)\Common Files\AMXShare\AXIs",

[Parameter(Mandatory = $false)]
[string]
$IncludePath = "C:\Program Files (x86)\Common Files\AMXShare\AXIs"
[switch]
$Delete = $false
)

try {
$Path = Resolve-Path $Path

$directories = Get-ChildItem -Path $Path -Directory -Recurse | Where-Object { $_.FullName -notmatch "(.git|.history|node_modules)" }
$prevPWD = $PWD
Set-Location $PSScriptRoot

$moduleFiles = $directories | Get-ChildItem -File -Include *.axs -ErrorAction SilentlyContinue
$includeFiles = $directories | Get-ChildItem -File -Include *.axi -ErrorAction SilentlyContinue
try {
$moduleFiles = Get-ChildItem -File "**/*.tko" -Recurse | Where-Object { $_.FullName -notmatch "(.git|.history|node_modules)" }
$includeFiles = Get-ChildItem -File "**/*.axi" -Recurse | Where-Object { $_.FullName -notmatch "(.git|.history|node_modules)" }

if (!$moduleFiles -and !$includeFiles) {
Write-Host "No files found in $Path" -ForegroundColor Yellow
exit
Write-Host "No files found"
exit 1
}

foreach ($file in $includeFiles) {
$path = Join-Path -Path $IncludePath -ChildPath $file.Name
$target = $file.FullName
$ModulePath = Resolve-Path $ModulePath
$IncludePath = Resolve-Path $IncludePath

Write-Host "Creating symlink: $path -> $target" -ForegroundColor Green
New-Item -ItemType SymbolicLink -Path $path -Target $target -Force | Out-Null
}
!$Delete ? (Write-Host "Creating symlinks...") : (Write-Host "Deleting symlinks...")

foreach ($file in $moduleFiles) {
if (!(Test-Path $($file.FullName -replace ".axs", ".tko"))) {
Write-Host "TKO file not found for $file" -ForegroundColor Yellow
foreach ($file in $includeFiles) {
$linkPath = "$IncludePath/$($file.Name)"

if ($Delete) {
Write-Verbose "Deleting symlink: $linkPath"
Remove-Item -Path $linkPath -Force | Out-Null
continue
}

$path = Join-Path -Path $ModulePath -ChildPath $file.Name

$target = $file.FullName
Write-Verbose "Creating symlink: $linkPath -> $target"
New-Item -ItemType SymbolicLink -Path $linkPath -Target $target -Force | Out-Null
}

Write-Host "Creating symlink: $path -> $target" -ForegroundColor Green
New-Item -ItemType SymbolicLink -Path $path -Target $target -Force | Out-Null
foreach ($file in $moduleFiles) {
$linkPath = "$ModulePath/$($file.Name)"

$path = Join-Path -Path $ModulePath -ChildPath $($file.Name -replace ".axs", ".tko")
$target = $file.FullName -replace ".axs", ".tko"
if ($Delete) {
Write-Verbose "Deleting symlink: $linkPath"
Remove-Item -Path $linkPath -Force | Out-Null
continue
}

Write-Host "Creating symlink: $path -> $target" -ForegroundColor Green
New-Item -ItemType SymbolicLink -Path $path -Target $target -Force | Out-Null
$target = $file.FullName
Write-Verbose "Creating symlink: $linkPath -> $target"
New-Item -ItemType SymbolicLink -Path $linkPath -Target $target -Force | Out-Null
}
}
catch {
Write-Host $_.Exception.GetBaseException().Message -ForegroundColor Red
exit 1
}

Write-Host
Read-Host -Prompt "Press any key to exit..."
finally {
Set-Location $prevPWD
}
78 changes: 78 additions & 0 deletions archive.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env pwsh

<#
_ _ _ ___ __
| \ | | ___ _ __ __ _ __ _| |_ ___ / \ \ / /
| \| |/ _ \| '__/ _` |/ _` | __/ _ \ / _ \ \ / /
| |\ | (_) | | | (_| | (_| | || __// ___ \ V /
|_| \_|\___/|_| \__, |\__,_|\__\___/_/ \_\_/
|___/
MIT License
Copyright (c) 2023 Norgate AV Services Limited
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
#>


[CmdletBinding()]

param (
[Parameter(Mandatory = $false)]
[string]
$Path = ".",

[Parameter(Mandatory = $false)]
[string]
$OutDir = "dist"
)

try {
$Path = Resolve-Path -Path $Path

$manifest = Get-Content -Path "$Path/manifest.json" -Raw | ConvertFrom-Json

if (!$manifest) {
Write-Error "No manifest.json file found in $Path"
exit 1
}

$version = $manifest.version
$name = $manifest.name

foreach ($file in $manifest.files) {
$files += @(Get-ChildItem -File $file -ErrorAction Stop | Where-Object { $_.FullName -notmatch "(.git|node_modules|.history|dist)" })
}

$files += @("manifest.json")

if (-not(Test-Path -Path "$Path/$OutDir")) {
New-Item -Path "$Path/$OutDir" -Type Directory | Out-Null
}

$zip = "$Path/$OutDir/$name.$version.archive.zip"
Compress-Archive -Path $files -DestinationPath $zip -Force

(Get-FileHash $zip).Hash.ToLower() | Out-File -FilePath "$zip.sha256" -Encoding ascii
}
catch {
Write-Host $_.Exception.GetBaseException().Message -ForegroundColor Red
exit 1
}
14 changes: 14 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "NAVDatabase.Amx.ExtronDMP",
"description": "NetLinx module for Extron DMP range of DSP's",
"version": "1.0.1",
"license": "MIT",
"files": ["**/*.axi", "src/*.tko", "SymLink.ps1", "LICENSE", "README.md"],
"repository": {
"type": "git",
"url": "https://github.com/Norgate-AV/NAVDatabase.Amx.ExtronDMP.git"
},
"bugs": {
"url": "https://github.com/Norgate-AV/NAVDatabase.Amx.ExtronDMP/issues"
}
}

0 comments on commit 9e226fd

Please sign in to comment.