Skip to content

Publish packages

Publish packages #53

Workflow file for this run

name: 'Publish packages'
on:
workflow_dispatch:
inputs:
deploy-sdk:
type: boolean
description: Deploy components of the SDK (Compiler, Chr, Toolset, Sdk, ProjectTemplates)
deploy-repl:
type: boolean
description: Deploy components of the REPL (Compiler, Chr, Repl)
deploy-coverage-tool:
type: boolean
description: Deploy the coverage tool (Coverage, Coverage.Toolset)
deploy-langserver:
type: boolean
description: Deploy the language server (Compiler, Chr, LanguageServer, Lsp)
deploy-debugadapter:
type: boolean
description: Deploy the debug adapter (DebugAdapter, Dap)
deploy-vscext:
type: boolean
description: Deploy the VS Code extension
version:
type: string
description: The version number to deploy with
required: true
prerelease:
type: boolean
description: The deployed version is pre-release
env:
DOTNET_VERSION: '8.0.x' # The .NET SDK version to use
CONFIGURATION: 'Release' # The configuration to use
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
VSC_MARKETPLACE_TOKEN: ${{ secrets.VSC_MARKETPLACE_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
PRERELEASE: ${{ github.event.inputs.prerelease }}
jobs:
deploy:
runs-on: windows-latest
steps:
# Set up environment
- name: Clone the repo
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 18
- name: Install VSCE
run: npm install -g @vscode/vsce
# Build and packaging
- name: Package .NET portion
run: |
cd src
$sdkProjects = "Compiler", "Chr", "Compiler.Toolset", "Sdk", "ProjectTemplates"
$replProjects = "Compiler", "Chr", "Repl"
$coverageToolProjects = "Coverage", "Coverage.Toolset"
$langserverProjects = "Compiler", "Chr", "LanguageServer", "Lsp", "JsonRpc"
$debugadapterProjects = "DebugAdapter", "Dap", "JsonRpc"
$projects = @()
if ($${{ github.event.inputs.deploy-sdk }}) { $projects += $sdkProjects; }
if ($${{ github.event.inputs.deploy-repl }}) { $projects += $replProjects; }
if ($${{ github.event.inputs.deploy-coverage-tool }}) { $projects += $coverageToolProjects; }
if ($${{ github.event.inputs.deploy-langserver }}) { $projects += $langserverProjects; }
if ($${{ github.event.inputs.deploy-debugadapter }}) { $projects += $debugadapterProjects; }
$projects = $projects | Select-Object -Unique
$version = "${{ env.VERSION }}"
if ($${{ env.PRERELEASE }}) { $version = "$version-pre"; }
foreach ($project in $projects)
{
$project = "Draco.$project"
dotnet pack $project --configuration ${{ env.CONFIGURATION }} /p:Version="$version"
}
cd ..
- name: Package VS Code extension
run: |
cd src/Draco.Extension.VsCode
if ($${{ github.event.inputs.deploy-vscext }})
{
Copy-Item "../../LICENSE" -Destination "LICENSE"
npm install
npm version "${{ env.VERSION }}"
if ($${{ env.PRERELEASE }}) { npm pkg set preview=true --json }
vsce package
}
cd ../..
# Publishing
- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: |
src/**/*.nupkg
src/**/*.vsix
- name: Upload to NuGet.org
run: |
cd src
$packages = Get-ChildItem -Recurse | Where { $_.Name -like "*.nupkg" -and $_.Name -notlike "*symbols*" }
foreach ($package in $packages)
{
dotnet nuget push $package.FullName --api-key ${{ env.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --no-symbols --skip-duplicate
}
cd ..
- name: Upload to VS Code Marketplace
run: |
cd src/Draco.Extension.VsCode
if ($${{ github.event.inputs.deploy-vscext }})
{
vsce publish --pat ${{ env.VSC_MARKETPLACE_TOKEN }}
}
cd ../..