Skip to content

Commit

Permalink
Start publishing to an internal Azure feed (#4)
Browse files Browse the repository at this point in the history
* Sign packages when publishing to NuGet.org (disabled until we have a first version to release)

* Do not push each package created in a PR, do the build and package and define an input argument to push a version of the package that is ready for integration and test.

* Publish changes on 'main' branch with the prerelease label 'trunk'
  • Loading branch information
anaiberta authored May 13, 2024
1 parent c50f227 commit c5896d0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
80 changes: 78 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Build
name: Build & Publish

on:
workflow_dispatch:
inputs:
force-dev-push:
description: 'Force publication of NuGet package of a developer version to an internal feed for test purpose'
required: false
default: 'false'
push:
branches: [ "main" ]
pull_request:
Expand All @@ -25,8 +30,79 @@ jobs:
with:
dotnet-version: 7.0.x

- name: Set Build Variables
id: buildVariables
run: |
$VersionTag = ''
$doPush = $true
switch -regex ($Env:GITHUB_REF_NAME) {
'^main' {
#$PUBLISH_TO_NUGETORG = 'true'
#---
# Temporary publish to an internal feed with prerelease tag 'trunk'
# while we are working in the first release
$PUBLISH_TO_NUGETORG = 'false'
$VersionTag = 'trunk'
#---
}
default {
$PUBLISH_TO_NUGETORG = 'false'
$VersionTag = "dev"
if ([string]::IsNullOrEmpty("${{ github.event.inputs.force-dev-push }}") ) {
$doPush = $false
} else {
$doPush = [System.Convert]::ToBoolean("${{ github.event.inputs.force-dev-push }}")
}
}
}
$NuGetPackageVersion = dotnet msbuild Directory.Build.props /t:GetPackageVersion
"$NuGetPackageVersion" -match "(?<=NuGetPackageVersion:)(.*)"
$NuGetPackageVersion = $Matches[0]
if ($VersionTag -ne '') {
$Timestamp = (Get-Date).ToUniversalTime().ToString("yyyyMMddHHmmss")
$NuGetPackageVersion = $NuGetPackageVersion + "-" + $VersionTag + "." + $Timestamp
}
echo "NuGetPackageVersion=$NuGetPackageVersion" >> $Env:GITHUB_ENV
echo "IS_PUBLISH_TO_NUGETORG=$PUBLISH_TO_NUGETORG" >> $Env:GITHUB_ENV
echo "DO_PACKAGE_PUSH=$doPush" >> $Env:GITHUB_ENV
write-host [INFO] NuGet Package Version: $NuGetPackageVersion
- name: Build & Pack
run: dotnet build --configuration $env:Configuration
run: dotnet build --configuration $env:Configuration -p:Version=$Env:NuGetPackageVersion

- name: Test
run: dotnet test --configuration $env:Configuration --no-build

- name: Sign packages
if: env.IS_PUBLISH_TO_NUGETORG == 'true'
env:
TIMESTAMPER_URL: ${{ secrets.CODE_SIGN_CERTIFICATE_TIMESTAMPER_URL }}
PFX_BASE64: ${{ secrets.CODE_SIGN_CERTIFICATE_BASE64 }}
PFX_PASS: ${{ secrets.CODE_SIGN_CERTIFICATE_PASSWORD }}
run: |
$codesign_pfx = "code_sign_cert.pfx"
$bytes = [Convert]::FromBase64String($Env:PFX_BASE64)
[IO.File]::WriteAllBytes($codesign_pfx, $bytes)
Get-ChildItem .\_packages\$Env:Configuration\*.nupkg -Recurse |
dotnet nuget sign $_.FullName --certificate-path $codesign_pfx --certificate-password $Env:PFX_PASS --timestamper $Env:TIMESTAMPER_URL
}
- name: Publish
if: env.DO_PACKAGE_PUSH == 'true'
run: |
if ( ${{ env.IS_PUBLISH_TO_NUGETORG }} ) {
dotnet nuget add source ${{ vars.NUGET_ORG_FEED }} --name NuGetFeed4Deploy --username gxbuilder --password ${{ secrets.NUGET_ORG_TOKEN }}
} else {
dotnet nuget add source ${{ vars.AZURE_NEXUS_PRERELEASES_FEED }} --name NuGetFeed4Deploy --username gxbuilder --password ${{ secrets.AZURE_ARTIFACTS_TOKEN }}
}
Get-ChildItem .\_packages\$Env:Configuration\*.nupkg -Recurse |
ForEach-Object {
dotnet nuget push $_.FullName --source NuGetFeed4Deploy --api-key DUMMY-KEY
}
5 changes: 4 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<LangVersion>latest</LangVersion>

<Version>0.0.14</Version>
<Version>1.0.0</Version>

<Product>GeneXus</Product>
<Company>GeneXus</Company>
Expand Down Expand Up @@ -45,4 +45,7 @@
</ItemGroup>
<!-- END: Define a default Readme.md file for NuGet packages -->

<Target Name="GetPackageVersion">
<Message Text="NuGetPackageVersion:$(PackageVersion)" Importance="high"/>
</Target>
</Project>

0 comments on commit c5896d0

Please sign in to comment.