Skip to content

Conversation

@dmilov
Copy link
Contributor

@dmilov dmilov commented May 17, 2021

Signed-off-by: Dimitar Milov dmilov@vmware.com

Add publish job to run on version tag

Signed-off-by: Dimitar Milov dmilov@vmware.com

Description

Implement a publishing script that

  • builds
  • test
  • publishes to PSGallery if and only if all tests pass and the module version is higher than the available on the PSGallery

Add GHA to trigger the publish script on version tag

Closes: #32

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.

  • [X ] Run publish.ps1 locally with bad NuGetAPIKey
> .\publish.ps1 -NuGetApiKey BAD
[1:03:33 PM] INFO: Publish CloudEvents.Sdk Module to 'C:\git-repos\github\sdk-powershell\CloudEvents.Sdk\CloudEvents.Sdk'
[1:03:35 PM] INFO: Run unit tests

Starting discovery in 9 files.
Discovery finished in 344ms.
[+] C:\git-repos\github\sdk-powershell\test\unit\ConvertFrom-HttpMessage.Tests.ps1 1.1s (360ms|564ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\ConvertTo-HttpMessage.Tests.ps1 396ms (153ms|204ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\New-CloudEvent.Tests.ps1 192ms (27ms|151ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\Read-CloudEventData.Tests.ps1 171ms (13ms|145ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\Read-CloudEventJsonData.Tests.ps1 196ms (45ms|134ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\Read-CloudEventXmlData.Tests.ps1 252ms (80ms|148ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\Set-CloudEventData.Tests.ps1 236ms (56ms|160ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\Set-CloudEventJsonData.Tests.ps1 186ms (20ms|157ms)
[+] C:\git-repos\github\sdk-powershell\test\unit\Set-CloudEventXmlData.Tests.ps1 210ms (64ms|136ms)
Tests completed in 2.99s
Tests Passed: 28, Failed: 0, Skipped: 0 NotRun: 0
[1:03:39 PM] INFO: Run integration tests

Starting discovery in 1 files.
Discovery finished in 196ms.
[+] C:\git-repos\github\sdk-powershell\test\integration\HttpIntegration.Tests.ps1 2.07s (1.4s|504ms)
Tests completed in 2.1s
Tests Passed: 5, Failed: 0, Skipped: 0 NotRun: 0
Performing operation: Publish-Module -Name CloudEvents.Sdk -RequiredVersion 0.2.1 -NuGetApiKey '...' -Repository PSGallery -Confirm:$false
Write-Error: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:10990
 Line |
10990 |Publish-PSArtifactUtility @PublishPSArtifactUtility_Param|                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Failed to publish module 'CloudEvents.Sdk': 'dotnet cli failed to nuget push Pushing
      | CloudEvents.Sdk.0.2.1.nupkg to 'https://www.powershellgallery.com/api/v2/package/'...   PUT
      | https://www.powershellgallery.com/api/v2/package/   Forbidden
      | https://www.powershellgallery.com/api/v2/package/ 1330ms error: Response status code does not
      | indicate success: 403 (The specified API key is invalid, has expired, or does not have permission to
      | access the specified package.).   Usage: dotnet nuget push [arguments] [options]  Arguments:   [root]
      | Specify the path to the package and your API key to push the package to the server.  Options:
      | -h|--help                      Show help information   --force-english-output         Forces the
      | application to run using an invariant, English-based culture.   -s|--source <source>
      | Package source (URL, UNC/folder path or package source name) to use. Defaults to DefaultPushSource if
      | specified in NuGet.Config.   -ss|--symbol-source <source>   Symbol server URL to use.   -t|--timeout
      | <timeout>         Timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).
      | -k|--api-key <apiKey>          The API key for the server.   -sk|--symbol-api-key <apiKey>  The API
      | key for the symbol server.   -d|--disable-buffering         Disable buffering when pushing to an
      | HTTP(S) server to decrease memory usage.   -n|--no-symbols                If a symbols package
      | exists, it will not be pushed to a symbols server.   --no-service-endpoint          Does not append
      | "api/v2/package" to the source URL.   --interactive                  Allow the command to block and
      | require manual action for operations like authentication.   --skip-duplicate               If a
      | package and version already exists, skip it and continue with the next package in the push, if any. '.

Test Configuration:

  • Toolchain:
  • SDK:
  • (add more if needed)

Checklist:

  • My code follows the contribution
    guidelines
    of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

SimeonGerginov
SimeonGerginov previously approved these changes May 17, 2021
Copy link

@SimeonGerginov SimeonGerginov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@embano1
Copy link
Member

embano1 commented May 17, 2021

If you prefix your commit with chore: it will show up nicely in the CHANGELOG :)

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Add publish job to run on version tag

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Segregate build and publish in steps

Use 'release' working directory for the release job

Use dir name instead of path

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

test publish script

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Create output directory if it doesn't exist

REmove resolve path to avoid failures in case of unexisting directory

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Work with full path

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Trigger action on tag create

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Add create github release step

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Create changle log step in the Release job

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Use PowerShell to run docker container for the CHANGELOG creation

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Run release job on ubuntu fot he purpose of the changelog creation

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Use default shell for docker command

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Use the tag for gh release

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Pick up changelog from previous step

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Rename workflow to 'release'

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

Address PR review comments

Signed-off-by: Dimitar Milov <dmilov@vmware.com>
@dmilov dmilov force-pushed the topic/publish-script branch from 8ac9857 to 78b7e9e Compare May 28, 2021 07:43
Copy link
Member

@embano1 embano1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX a ton!

@embano1
Copy link
Member

embano1 commented Jun 8, 2021

Approved! Note: if you prefix the commit with chore: it will nicely render in the CHANGELOG.

@dmilov dmilov merged commit c047c13 into cloudevents:main Jun 8, 2021
@embano1 embano1 mentioned this pull request Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement publish.ps1 for publishing the module to PSGallery

3 participants