Skip to content

Commit

Permalink
test nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
ldennington committed Oct 11, 2023
1 parent dba839c commit 3ddb213
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 203 deletions.
86 changes: 18 additions & 68 deletions .github/workflows/nuget-test-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
# ================================
# .NET Tool
# ================================
dotnet-tool-payload-sign:
name: Build .NET tool and Sign Payload
create-dotnet-tool-artifacts:
name: Create .NET Tool Artifacts
runs-on: windows-latest
environment: release
needs: prereqs
steps:
- uses: actions/checkout@v4
Expand All @@ -35,10 +36,15 @@ jobs:
dotnet-version: 7.0.x

- name: Build .NET tool
shell: bash
run: |
$GITHUB_WORKSPACE/src/shared/DotnetTool/layout.sh `
--configuration=Release
& $env:GITHUB_WORKSPACE\src\shared\DotnetTool\layout.ps1 Release
# The AzureCodeSigning PowerShell module currently cannot handle files
# without extensions. This is a temporary workaround until the issue is
# fixed.
mkdir $env:GITHUB_WORKSPACE\incompatible-files
Get-ChildItem -Path $env:GITHUB_WORKSPACE\out\shared\DotnetTool\nupkg\Release\payload\* `
-Include NOTICE | Move-Item -Destination `
$env:GITHUB_WORKSPACE\incompatible-files
- name: Log into Azure
uses: azure/login@v1
Expand All @@ -53,87 +59,31 @@ jobs:
endpoint: https://wus2.codesigning.azure.net/
code-signing-account-name: git-fundamentals-signing
certificate-profile-name: git-fundamentals-windows-signing
files-folder: ${{ github.workspace }}\out\shared\DotnetTool\nupkg\Release
files-folder: ${{ github.workspace }}\out\shared\DotnetTool\nupkg\Release\payload
files-folder-filter: exe,dll
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256

- name: Lay out signed payload, images, and symbols
shell: bash
run: |
mkdir dotnet-tool-payload-sign
rm -rf payload
mv images payload.sym -t dotnet-tool-payload-sign
unzip signed/payload.zip -d dotnet-tool-payload-sign
- name: Upload signed payload
uses: actions/upload-artifact@v3
with:
name: dotnet-tool-payload-sign
path: |
dotnet-tool-payload-sign
dotnet-tool-pack:
name: Package .NET tool
runs-on: ubuntu-latest
needs: [ prereqs, dotnet-tool-payload-sign ]
steps:
- uses: actions/checkout@v4

- name: Download signed payload
uses: actions/download-artifact@v3
with:
name: dotnet-tool-payload-sign
path: signed
timestamp-digest: SHA256

# The Azure Code Signing action overrides the .NET version, so we reset it.
- name: Set up .NET
uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: 7.0.x

- name: Package tool
run: |
src/shared/DotnetTool/pack.sh --configuration=Release \
--version="${{ needs.prereqs.outputs.version }}" \
--publish-dir=$(pwd)/signed
- name: Upload unsigned package
uses: actions/upload-artifact@v3
with:
name: tmp.dotnet-tool-package-unsigned
path: |
out/shared/DotnetTool/nupkg/Release/*.nupkg
dotnet-tool-sign:
name: Sign .NET tool package
# ESRP service requires signing to run on Windows
runs-on: windows-latest
environment: release
needs: dotnet-tool-pack
steps:
- uses: actions/checkout@v4

- name: Download unsigned package
uses: actions/download-artifact@v3
with:
name: tmp.dotnet-tool-package-unsigned
path: nupkg
& $env:GITHUB_WORKSPACE\src\shared\DotnetTool\pack.ps1 Release `
${{ needs.prereqs.outputs.version }} "$pwd.Path\signed"
- name: Zip unsigned package
shell: pwsh
run: |
Compress-Archive -Path nupkg/*.nupkg nupkg/gcm-nupkg.zip
Compress-Archive -Path out/shared/DotnetTool/nupkg/Release/git-credential-manager.${{ needs.prereqs.outputs.version }}.nupkg `
nupkg/gcm-nupkg.zip
cd nupkg
Get-ChildItem -Exclude gcm-nupkg.zip | Remove-Item -Recurse -Force
- name: Log into Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Set up ESRP client
shell: pwsh
env:
Expand Down
56 changes: 56 additions & 0 deletions src/shared/DotnetTool/layout.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Inputs
param ([Parameter(Mandatory)] $CONFIGURATION)

# Directories
$THISDIR = $MyInvocation.MyCommand.Path | Split-Path -Parent
$ROOT = (Get-Item $THISDIR).parent.parent.parent.FullName
$SRC = "$ROOT/src"
$OUT = "$ROOT/out"
$GCM_SRC = "$SRC/shared/Git-Credential-Manager"
$DOTNET_TOOL = "shared/DotnetTool"
$PROJ_OUT = "$OUT/$DOTNET_TOOL"
$FRAMEWORK = "net7.0"

# Outputs
$OUTDIR = "$PROJ_OUT/nupkg/$CONFIGURATION"
$IMGOUT = "$OUTDIR/images"
$PAYLOAD = "$OUTDIR/payload"
$SYMBOLOUT = "$OUTDIR/payload.sym"

# Clean up any old payload and symbols directories
if (Test-Path -Path $OUTDIR)
{
Write-Output "Cleaning old payload directory '$OUTDIR'..."
Remove-Item -Recurse "$OUTDIR" -Force
}

# Ensure payload and symbol directories exist
mkdir -p "$IMGOUT","$PAYLOAD","$SYMBOLOUT"

# Set DOTNET_ROOT if needed
$DOTNET_SET = Get-Item "Env:DOTNET_ROOT" -ErrorAction SilentlyContinue
if (!$DOTNET_SET) {
$Env:DOTNET_ROOT = (Get-Command dotnet).Path | Split-Path -Parent
}

# Publish core application executables
Write-Output "Publishing core application..."
& "$env:DOTNET_ROOT\dotnet.exe" publish "$GCM_SRC" `
--configuration="$CONFIGURATION" `
--framework="$FRAMEWORK" `
--output="$PAYLOAD" `
-p:UseAppHost=false

# Collect symbols
Write-Output "Collecting managed symbols..."
Copy-Item -Path "$PAYLOAD/*.pdb" -Destination "$SYMBOLOUT"

# Copy DotnetToolSettings.xml file
Write-Output "Copying out package configuration files..."
Copy-Item -Path "$SRC/$DOTNET_TOOL/DotnetToolSettings.xml" -Destination "$PAYLOAD/"

# Copy package icon image
Write-Output "Copying images..."
Copy-Item -Path "$SRC/$DOTNET_TOOL/icon.png" -Destination "$IMGOUT"

Write-Output "Layout complete."
83 changes: 0 additions & 83 deletions src/shared/DotnetTool/layout.sh

This file was deleted.

27 changes: 27 additions & 0 deletions src/shared/DotnetTool/pack.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Inputs
param ([Parameter(Mandatory)] $CONFIGURATION, [Parameter(Mandatory)] $VERSION, $PUBLISH_DIR)

# Directories
$THISDIR = $MyInvocation.MyCommand.Path | Split-Path -Parent
$ROOT = (Get-Item $THISDIR).parent.parent.parent.FullName
$SRC = "$ROOT/src"
$OUT = "$ROOT/out"
$DOTNET_TOOL = "shared/DotnetTool"

if ([string]::IsNullOrEmpty($PUBLISH_DIR)) {
$PUBLISH_DIR = "$OUT/$DOTNET_TOOL/nupkg/$CONFIGURATION"
}

# Set DOTNET_ROOT if needed
$DOTNET_SET = Get-Item "Env:DOTNET_ROOT" -ErrorAction SilentlyContinue
if (!$DOTNET_SET) {
$Env:DOTNET_ROOT = (Get-Command dotnet).Path | Split-Path -Parent
}

Write-Output "Creating dotnet tool package..."
& "$env:DOTNET_ROOT\dotnet.exe" pack "$SRC/$DOTNET_TOOL/DotnetTool.csproj" `
/p:Configuration="$CONFIGURATION" `
/p:PackageVersion="$VERSION" `
/p:PublishDir="$PUBLISH_DIR/"

Write-Output "Dotnet tool pack complete."
52 changes: 0 additions & 52 deletions src/shared/DotnetTool/pack.sh

This file was deleted.

0 comments on commit 3ddb213

Please sign in to comment.