Publish packages #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Publish packages' | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy-sdk: | |
type: boolean | |
description: Deploy components of the SDK (Compiler, Toolset, Sdk, ProjectTemplates) | |
deploy-langserver: | |
type: boolean | |
description: Deploy the language server (Compiler, LanguageServer) | |
deploy-debugadapter: | |
type: boolean | |
description: Deploy the debug adapter (DebugAdapter) | |
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: '7.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", "Compiler.Toolset", "Sdk", "ProjectTemplates" | |
$langserverProjects = "Compiler", "LanguageServer" | |
$debugadapterProjects = @("DebugAdapter") | |
$projects = @() | |
if ($${{ github.event.inputs.deploy-sdk }}) { $projects += $sdkProjects; } | |
if ($${{ github.event.inputs.deploy-langserver }}) { $projects += $langserverProjects; } | |
if ($${{ github.event.inputs.deploy-debugadapter }}) { $projects += $debugadapterProjects; } | |
$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 ../.. |