-
Notifications
You must be signed in to change notification settings - Fork 7
Implement publish script #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # ************************************************************************** | ||
| # Copyright (c) Cloud Native Foundation. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ************************************************************************** | ||
|
|
||
| name: Release | ||
|
|
||
| on: | ||
| create: | ||
| tags: | ||
| - v* | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| psgallery-publish: | ||
| name: Release CloudEvents.Sdk Module | ||
| runs-on: "ubuntu-latest" | ||
| env: | ||
| OUTPUT_DIR: release | ||
| CHANGE_LOG_FILE_NAME: RELEASE_CHANGELOG.md | ||
|
|
||
| timeout-minutes: 10 | ||
|
|
||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Build and Test | ||
| shell: pwsh | ||
| run: ./build.ps1 -OutputDir $env:OUTPUT_DIR -TestsType all -ExitProcess | ||
|
|
||
| - name: Publish to PSGallery | ||
| shell: pwsh | ||
| run: ./publish.ps1 -ModuleReleaseDir $env:OUTPUT_DIR -NuGetApiKey ${{ secrets.CLOUDEVENTS_SDK_PUBLISHER_API_KEY }} | ||
|
|
||
| - name: Create CHANGELOG | ||
| env: | ||
| IMAGE: quay.io/git-chglog/git-chglog | ||
| # https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2 | ||
| IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3 | ||
| run: | | ||
| # generate CHANGELOG for this Github release tag only | ||
| docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} -o ${CHANGE_LOG_FILE_NAME} $(basename "${{ github.ref }}" ) | ||
|
|
||
| - name: Create Github Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: gh release create $(basename "${{ github.ref }}") -F ${CHANGE_LOG_FILE_NAME} | ||
|
|
||
| changelog-pull-request: | ||
| needs: psgallery-publish | ||
| name: Create CHANGELOG PR | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: true | ||
| env: | ||
| CHANGE_LOG_FILE_NAME: CHANGELOG.md | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| # for changelog | ||
| fetch-depth: 0 | ||
| ref: "main" | ||
|
|
||
| - name: Create CHANGELOG commit | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| IMAGE: quay.io/git-chglog/git-chglog | ||
| # https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2 | ||
| IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3 | ||
| run: | | ||
| # update CHANGELOG.md | ||
| docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} -o ${CHANGE_LOG_FILE_NAME} | ||
|
|
||
| git config user.email "${{ github.actor }}@users.noreply.github.com" | ||
| git config user.name "${{ github.actor }}" | ||
| git add ${CHANGE_LOG_FILE_NAME} | ||
| git commit -m "Update CHANGELOG for $(basename ${{ github.ref }})" | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@v3 | ||
| with: | ||
| delete-branch: true | ||
| title: "Update CHANGELOG" | ||
| body: | | ||
| Update CHANGELOG.md for new release | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # ************************************************************************** | ||
| # Copyright (c) Cloud Native Foundation. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ************************************************************************** | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Publish the CloudEvents.Sdk module to PSGallery | ||
|
|
||
| .PARAMETER NuGetApiKey | ||
| PowerShell Gallery API Key to be used to publish the module | ||
|
|
||
| .PARAMETER ModuleReleaseDir | ||
| Parent directory of the 'CloudEvents.Sdk' module that will be published | ||
| #> | ||
|
|
||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [string] | ||
| $NuGetApiKey, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [ValidateScript({ Test-Path $_ })] | ||
| [string] | ||
| $ModuleReleaseDir | ||
| ) | ||
|
|
||
| # Work with full path in case relative path is provided | ||
| $ModuleReleaseDir = (Resolve-Path $ModuleReleaseDir).Path | ||
|
|
||
| $moduleName = 'CloudEvents.Sdk' | ||
|
|
||
| # Build is successful and all tests pass | ||
| $env:PSModulePath += [IO.Path]::PathSeparator + $ModuleReleaseDir | ||
|
|
||
| $localModule = Get-Module $moduleName -ListAvailable | ||
| $psGalleryModule = Find-Module -Name $moduleName -Repository PSGallery | ||
|
|
||
| # Throw an exception if module with the same version is availble on PSGallery | ||
| if ( $null -ne $psGalleryModule -and ` | ||
| $null -ne $localModule -and ` | ||
| $psGalleryModule.Version -eq $localModule.Version ) { | ||
| throw "'$moduleName' module with version '$($localModule.Version)' is already available on PSGallery" | ||
| } | ||
|
|
||
| Write-Host "Performing operation: Publish-Module -Name $moduleName -RequiredVersion $($localModule.Version) -NuGetApiKey *** -Repository PSGallery -Confirm:`$false" | ||
| Publish-Module -Name $moduleName -RequiredVersion $localModule.Version -NuGetApiKey $NuGetApiKey -Repository PSGallery -Confirm:$false -ErrorAction Stop |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.