diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 129f4e0a3d..34f5af6df7 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -72,7 +72,7 @@ jobs: - name: Set up uses: ./.github/setup - + - name: Add internal NuGet feed run: ./ci/scripts/Add-InternalNuGetFeed.ps1 ` -internalFeed "${{ secrets.AZURE_ARTIFACTS_FEED }}" ` @@ -103,7 +103,7 @@ jobs: -rigantiSecret "${{ secrets.SIGN_RIGANTI_SECRET }}" ` -rigantiCertificate "${{ secrets.SIGN_RIGANTI_CERTIFICATE_NAME }}" - publish-dotvvm-types: + publish-npm: runs-on: windows-2022 needs: read-input steps: @@ -129,10 +129,23 @@ jobs: cat "${{ github.workspace }}/ci/scripts/npm/dotvvm-types/package.json"; working-directory: ci/scripts/npm/dotvvm-types + - name: Build JsComponent.React + run: | + npm ci + npm version "${{ needs.read-input.outputs.version }}" --no-git-tag-version + npm pack + working-directory: src/Framework/JsComponent.React + + - name: Build JsComponent.Svelte + run: | + npm ci + npm version "${{ needs.read-input.outputs.version }}" --no-git-tag-version + npm pack + working-directory: src/Framework/JsComponent.Svelte + - name: Set internal npm registry run: > ./ci/scripts/Set-NpmRegistry.ps1 ` - -targetDirectory "./ci/scripts/npm/dotvvm-types" ` -registry "${{ secrets.INTERNAL_NPM_REGISTRY }}" ` -pat "${{ secrets.INTERNAL_NPM_PAT }}" ` -username "${{ secrets.INTERNAL_NPM_USERNAME }}" ` @@ -141,3 +154,11 @@ jobs: - name: Publish dotvvm-types run: npm publish working-directory: ci/scripts/npm/dotvvm-types + + - name: Publish JsComponent.React + run: npm publish + working-directory: src/Framework/JsComponent.React + + - name: Publish JsComponent.Svelte + run: npm publish + working-directory: src/Framework/JsComponent.Svelte diff --git a/ci/scripts/CopyBetweenNugetFeeds.ps1 b/ci/scripts/CopyBetweenNugetFeeds.ps1 deleted file mode 100644 index e5169663a6..0000000000 --- a/ci/scripts/CopyBetweenNugetFeeds.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -Param( - [string]$version, - [string]$server, - [string]$internalServer, - [string]$internalSnupkgServer, - [string]$apiKey -) - - -### Configuration -$packages = @( - [pscustomobject]@{ Package = "DotVVM.Core"; Directory = "Framework/Core"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM"; Directory = "Framework/Framework" ; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Owin"; Directory = "Framework/Hosting.Owin"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.AspNetCore"; Directory = "Framework/Hosting.AspNetCore" ; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Testing"; Directory = "Framework/Testing" ; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.CommandLine"; Directory = "Tools/CommandLine"; Type = "tool" }, - [pscustomobject]@{ Package = "DotVVM.Templates"; Directory = "Templates" ; Type = "template" }, - [pscustomobject]@{ Package = "DotVVM.Api.Swashbuckle.AspNetCore"; Directory = "Api/Swashbuckle.AspNetCore"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Api.Swashbuckle.Owin"; Directory = "Api/Swashbuckle.Owin"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.HotReload"; Directory = "Tools/HotReload/Common"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.HotReload.AspNetCore"; Directory = "Tools/HotReload/AspNetCore"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.HotReload.Owin"; Directory = "Tools/HotReload/Owin"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.DynamicData"; Directory = "DynamicData/DynamicData"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.DynamicData.Annotations"; Directory = "DynamicData/Annotations"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.AutoUI"; Directory = "AutoUI/Core"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.AutoUI.Annotations"; Directory = "AutoUI/Annotations"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Tracing.ApplicationInsights"; Directory = "Tracing/ApplicationInsights"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Tracing.ApplicationInsights.AspNetCore"; Directory = "Tracing/ApplicationInsights.AspNetCore"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Tracing.ApplicationInsights.Owin"; Directory = "Tracing/ApplicationInsights.Owin"; Type = "standard" } - [pscustomobject]@{ Package = "DotVVM.Tracing.MiniProfiler.AspNetCore"; Directory = "Tracing/MiniProfiler.AspNetCore"; Type = "standard" }, - [pscustomobject]@{ Package = "DotVVM.Tracing.MiniProfiler.Owin"; Directory = "Tracing/MiniProfiler.Owin"; Type = "standard" } -) - -Write-Host "Current directory: $PWD" - -$webClient = New-Object System.Net.WebClient -## Standard packages -foreach ($package in $packages) { - - $packageId = $package.Package - - Write-Host "Downloading $packageId ($version)" - - # standard package - if ($package.Type -eq "standard") { - & ../ci/scripts/nuget.exe install $packageId -OutputDirectory .\tools\packages -version $version -DirectDownload -NoCache -DependencyVersion Ignore -source $internalServer | Out-Host - $nupkgFile = dir -s ./tools/packages/$packageId.$version.nupkg | Select -First 1 - Write-Host "Downloaded package located on '$nupkgFile'" - } - # standard package - if ($package.Type -eq "tool") { - ## dotnet tools - dotnet tool install $packageId --tool-path ./tools/packages --version $version --add-source $internalServer | Out-Host - $nupkgFile = dir -s ./tools/packages/*/$packageId.$version.nupkg | Select -First 1 - Write-Host "Downloaded tool located on '$nupkgFile'" - } - # dotnet templates - if ($package.Type -eq "template") { - dotnet new --install "$packageId::$version" --force --nuget-source $internalServer | Out-Host - $nupkgFile = dir -s $env:USERPROFILE/.templateengine/dotnetcli -filter $packageId.$version.nupkg | Select -First 1 - Write-Host "Downloaded template located on '$nupkgFile'" - } - - if ($nupkgFile) { - # upload - Write-Host "Uploading package..." - & ../ci/scripts/nuget.exe push $nupkgFile -source $server -apiKey $apiKey | Out-Host - Write-Host "Package uploaded to $server." - } - if (Test-Path -Path ./tools/packages) { - Remove-Item -Recurse -Force ./tools/packages - } - - # snupkg management - - $snupkgUrl = "file://$internalSnupkgServer/snupkg/"+$packageId + "." + $version + ".snupkg" - $snupkgFile = Join-Path $PSScriptRoot ($packageId + "." + $version + ".snupkg") - - try { - $webClient.DownloadFile($snupkgUrl, $snupkgFile) - $snupkgDownloaded = $true; - } catch { - Write-Host "No snupkg package found!" - $snupkgDownloaded = $false; - } - - if ($snupkgDownloaded -eq $true){ - Write-Host "Uploading snupkg package..." - & ../ci/scripts/nuget.exe push $snupkgFile -source $server -apiKey $apiKey | Out-Host - Write-Host "Uploaded snupkg package." - try { - Remove-Item $snupkgFile - } catch { - Write-Host "Unable to cleanup snupkg..." - } - } -} diff --git a/ci/scripts/CopyPackageBetweenNugetFeeds.ps1 b/ci/scripts/CopyPackageBetweenNugetFeeds.ps1 deleted file mode 100644 index a5e230a1a8..0000000000 --- a/ci/scripts/CopyPackageBetweenNugetFeeds.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -Param( - [string]$version, - [string]$server, - [string]$internalServer, - [string]$internalSnupkgServer, - [string]$apiKey, - [string]$packageId -) - - $packageId = $package.Package - $webClient = New-Object System.Net.WebClient - $url = "$internalServer/package/" + $packageId + "/" + $version - $nupkgFile = Join-Path $PSScriptRoot ($packageId + "." + $version + ".nupkg") - - - Write-Host "Downloading from $url" - $webClient.DownloadFile($url, $nupkgFile) - Write-Host "Package downloaded from '$internalServer'." - - Write-Host "Uploading package..." - & .\Tools\nuget.exe push $nupkgFile -source $server -apiKey $apiKey - Write-Host "Package uploaded to $server." - - Remove-Item $nupkgFile - - # snupkg management - $snupkgUrl = "file://$internalSnupkgServer/snupkg/" - $snupkgFile = Join-Path $PSScriptRoot ($packageId + "." + $version + ".snupkg") - - try { - $webClient.DownloadFile($snupkgUrl, $snupkgFile) - $snupkgDownloaded = $true; - }catch { - Write-Host "No snupkg package found!" - $snupkgDownloaded = $false; - } - - if ($snupkgDownloaded -eq $true){ - Write-Host "Uploading snupkg package..." - & .\Tools\nuget.exe push $snupkgFile -source $server -apiKey $apiKey - Remove-Item $nupkgFile - try {Remove-Item $snupkgFile}catch { - Write-Host "Unable to cleanup snupkg..." - } - } diff --git a/ci/scripts/Set-NpmRegistry.ps1 b/ci/scripts/Set-NpmRegistry.ps1 index 9ec925ff2e..ac10c98f7d 100644 --- a/ci/scripts/Set-NpmRegistry.ps1 +++ b/ci/scripts/Set-NpmRegistry.ps1 @@ -14,23 +14,26 @@ if (-not ([string]::IsNullOrWhiteSpace("$targetDirectory"))) { throw "Target directory '$targetDirectory' does not exist." } Set-Location $targetDirectory + $location = "project" +} else { + $location = "user" } try { $feed = "$registry".Trim("https:"); - npm config set --location project "registry=$registry" + npm config set --location $location "registry=$registry" if ($username) { - npm config set --location project "${feed}:username=$username" + npm config set --location $location "${feed}:username=$username" } if ($email) { - npm config set --location project "${feed}:email=$email" + npm config set --location $location "${feed}:email=$email" } if ($pat) { $password = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$pat")); - npm config set --location project "${feed}:_password=$password" + npm config set --location $location "${feed}:_password=$password" } if ($authToken) { - npm config set --location project "${feed}:_authToken=$authToken" + npm config set --location $location "${feed}:_authToken=$authToken" } } finally { diff --git a/ci/scripts/npm/build-dotvvm-types.ps1 b/ci/scripts/npm/build-dotvvm-types.ps1 deleted file mode 100644 index a616ecba57..0000000000 --- a/ci/scripts/npm/build-dotvvm-types.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -param([Parameter(Mandatory=$true)] $version) - -$dir = pwd -push-location ../../../src/Framework/Framework - -npm run tsc-types -if (-not (test-path "$dir/dotvvm-types/types")) { - mkdir "$dir/dotvvm-types/types" -} -copy ./obj/typescript-types/dotvvm.d.ts "$dir/dotvvm-types/types/index.d.ts" - -pop-location - -push-location dotvvm-types - -npm version $version --no-git-tag-version - -pop-location \ No newline at end of file diff --git a/ci/scripts/nuget.exe b/ci/scripts/nuget.exe deleted file mode 100644 index 1a67d80c97..0000000000 Binary files a/ci/scripts/nuget.exe and /dev/null differ diff --git a/ci/scripts/publish.ps1 b/ci/scripts/publish.ps1 deleted file mode 100644 index e7cdcc174c..0000000000 --- a/ci/scripts/publish.ps1 +++ /dev/null @@ -1,169 +0,0 @@ -param( - [String]$version, - [String]$apiKey, - [String]$server, - [String]$branchName, - [String]$repoUrl, - [String]$nugetRestoreAltSource = "", - [bool]$pushTag, - [String]$configuration, - [String]$apiKeyInternal, - [String]$internalServer, - [String]$signUser = "", - [String]$signSecret = "", - $signConfigPath = "") -$currentDirectory = $PWD - -### Helper Functions - -function Invoke-Git { - <# -.Synopsis -Wrapper function that deals with Powershell's peculiar error output when Git uses the error stream. -.Example -Invoke-Git ThrowError -$LASTEXITCODE -#> - [CmdletBinding()] - param( - [parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments - ) - - & { - [CmdletBinding()] - param( - [parameter(ValueFromRemainingArguments = $true)] - [string[]]$InnerArgs - ) - git.exe $InnerArgs 2>&1 - } -ErrorAction SilentlyContinue -ErrorVariable fail @Arguments - - if ($fail) { - $fail.Exception - } -} -function CleanOldGeneratedPackages() { - Write-Host "Cleaning old versions of nupkg ..." - foreach ($package in $packages) { - del .\$($package.Path)\bin\$configuration\*.nupkg -ErrorAction SilentlyContinue - del .\$($package.Path)\bin\$configuration\*.snupkg -ErrorAction SilentlyContinue - } -} - -function RestoreSignClient() { - & dotnet tool restore | Out-Host -} - -function BuildPackages() { - Write-Host "Build started" - $originDirecotry = $PWD - foreach ($package in $packages) { - cd .\$($package.Path) - Write-Host "Building in directory $PWD" - - if ($nugetRestoreAltSource -eq "") { - & dotnet restore | Out-Host - } - else { - & dotnet restore --source $nugetRestoreAltSource --source https://nuget.org/api/v2/ | Out-Host - } - Write-Host "Packing project in directory $PWD" - - & dotnet pack -p:version=$version -p:ContinuousIntegrationBuild=true -c $configuration | Out-Host - cd $originDirecotry - } -} - -function SignPackages() { - if ($signUser -ne "") { - Write-Host "Signing packages ..." - foreach ($package in $packages) { - $baseDir = Join-Path $currentDirectory ".\$($package.Path)\bin\$configuration\" - Write-Host "Signing $($package.Name + " " + $version) (Base dir: $baseDir)" - & dotnet signclient sign --baseDirectory "$baseDir" --input *.nupkg --config "$signConfigPath" --user "$signUser" --secret "$signSecret" --name "$($package.Name)" --description "$($package.Name + " " + $version)" --descriptionUrl "https://github.com/riganti/dotvvm" | Out-Host - } - } -} - -function PushPackages() { - Write-Host "Pushing packages ..." - foreach ($package in $packages) { - & ../ci/scripts/nuget.exe push .\$($package.Path)\bin\$configuration\$($package.Package).$version.nupkg -source $server -apiKey $apiKey | Out-Host - & ../ci/scripts/nuget.exe push .\$($package.Path)\bin\$configuration\$($package.Package).$version.snupkg -source $server -apiKey $apiKey | Out-Host - } -} - -function BuildTemplates() { - cd $currentDirectory - - Write-Host "Building templates ..." - del .\Templates\*.nupkg -ErrorAction SilentlyContinue - - $filePath = ".\Templates\DotVVM.Templates.nuspec" - $file = [System.IO.File]::ReadAllText($filePath, [System.Text.Encoding]::UTF8) - $file = [System.Text.RegularExpressions.Regex]::Replace($file, "\([^<]+)\", "" + $version + "") - [System.IO.File]::WriteAllText($filePath, $file, [System.Text.Encoding]::UTF8) - - & ../ci/scripts/nuget.exe pack .\Templates\DotVVM.Templates.nuspec -outputdirectory .\Templates | Out-Host -} - -function SignTemplates() { - Write-Host "Signing templates ..." - if ($signUser -ne "") { - $baseDir = Join-Path $currentDirectory ".\Templates\" - & dotnet signclient sign --baseDirectory "$baseDir" --input *.nupkg --config "$signConfigPath" --user "$signUser" --secret "$signSecret" --name "DotVVM.Templates" --description "DotVVM.Templates $version" --descriptionUrl "https://github.com/riganti/dotvvm" | Out-Host - } -} - -function PublishTemplates() { - Write-Host "Publishing templates ..." - & ../ci/scripts/nuget.exe push .\Templates\DotVVM.Templates.$version.nupkg -source $server -apiKey $apiKey | Out-Host -} - -function GitCheckout() { - invoke-git checkout $branchName - invoke-git -c http.sslVerify=false pull $repoUrl $branchName -} - -function GitPush() { - - invoke-git config --global user.email "rigantiteamcity" - invoke-git config --global user.name "Riganti Team City" - if ($pushTag) { - invoke-git tag "v$($version)" HEAD - } - invoke-git push --follow-tags $repoUrl $branchName -} - - - -### Configuration - -$packages = . "$PSScriptRoot/Get-PublicProjects.ps1" | Where-Object { $_.Type -ne "template" } - - -### Publish Workflow - -$versionWithoutPre = $version -if ($versionWithoutPre.Contains("-")) { - $versionWithoutPre = $versionWithoutPre.Substring(0, $versionWithoutPre.IndexOf("-")) -} - -if ($branchName.StartsWith("refs/heads/") -eq $true) { - $branchName = $branchName.Substring("refs/heads/".Length) -} - -CleanOldGeneratedPackages; -RestoreSignClient; -GitCheckout; -BuildPackages; - -SignPackages; -PushPackages; - -BuildTemplates; -SignTemplates; -PublishTemplates; - -GitPush;