Skip to content

Commit f9122db

Browse files
Add yaml for a Release build (#129)
* Refactors the CI build yaml so that there can be a release build that benefits from the same template content. * Updates the documentation for releasing updated modules. * Refreshes the list of contributors to the project.
1 parent 2dd05e7 commit f9122db

File tree

8 files changed

+535
-83
lines changed

8 files changed

+535
-83
lines changed

CONTRIBUTING.md

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ Looking for information on how to use this module? Head on over to [README.md](
3030
* [Automated Tests](#automated-tests)
3131
* [New Test Guidelines](#new-test-guidelines)
3232
* [Releasing](#releasing)
33+
* [Updating the Version Number](#updating-the-version-number)
34+
* [Semantic Versioning](#semantic-versioning)
3335
* [Updating the CHANGELOG](#updating-the-changelog)
3436
* [Adding a New Tag](#adding-a-new-tag)
35-
* [Publish a Signed Update to PowerShell Gallery](#publish-a-signed-update-to-PowerShellGallery)
37+
* [Running the Release Build](#running-the-release-build)
3638
* [Contributors](#contributors)
3739
* [Legal and Licensing](#legal-and-licensing)
3840

@@ -375,10 +377,31 @@ any possible name collisions with existing objects on the executing user's accou
375377

376378
### Releasing
377379

378-
If you are a maintainer:
380+
When new code changes are checked in to the repo, most users of the module will not see those changes
381+
unless an updated module gets published by Microsoft to
382+
[PowerShell Gallery](https://www.powershellgallery.com/packages/PowerShellForGitHub).
379383

380-
Ensure that the version number of the module is updated with every pull request that is being
381-
accepted.
384+
The general guidance on publishing an update is that changes should not be in `master` more than
385+
one week without having been published through PowerShell Gallery as well.
386+
387+
When you are ready to publish a new update, the following steps are necessary:
388+
* Create (and complete) a changelist that:
389+
* Updates the [version number](#updating-the-version-number)
390+
* Updates the [CHANGELOG.md](./CHANGELOG.md) (and [contributors](#contributors) list if necessary)
391+
* [Add a tag](#adding-a-new-tag) for the new version to the repo
392+
* [Queue a new release build](#running-the-release-build)
393+
394+
#### Updating the Version Number
395+
396+
Whenever new changes to the module are to be released to PowerShellGallery, it is important to
397+
properly update the version of the module. The version number is stored in the module manifest
398+
([PowerShellForGitHub.psd1](https://github.com/microsoft/PowerShellForGitHub/blob/master/PowerShellForGitHub.psd1)),
399+
and it should be updated following the [Semantic Versioning](#semantic-versioning) standard.
400+
401+
> The update to the module manifest should happen in the same changelist where the
402+
> [CHANGELOG is updated](#updating-the-changelog).
403+
404+
##### Semantic Versioning
382405

383406
This project follows [semantic versioning](http://semver.org/) in the following way:
384407

@@ -389,49 +412,53 @@ Where:
389412
* `<minor>` - If this is a feature update, increment by one and be sure to reset `<patch>` to 0.
390413
* `<patch>` - If this is a bug fix, leave `<minor>` alone and increment this by one.
391414

392-
When new code changes are checked in to the repo, the module must be signed and published by
393-
Microsoft to [PowerShell Gallery](https://www.powershellgallery.com/packages/PowerShellForGitHub).
394-
395-
Once the new version has been pulled into master, there are additional tasks to perform:
396-
397-
* Ensure that [all tests pass](#testing) and that the module is still [static analysis clean](#static-analysis)
398-
* Update [CHANGELOG.md](./CHANGELOG.md)
399-
* Add a tag for that version to the repo
400-
* Publish a _signed_ update to [PowerShellGallery](https://www.powershellgallery.com/packages/PowerShellForGitHub/).
401-
402415
#### Updating the CHANGELOG
403416
To update [CHANGELOG.md](./CHANGELOG.md), just duplicate the previous section and update it to be
404417
relevant for the new release. Be sure to update all of the sections:
405418
* The version number
406-
* The hard path to the change (we'll get that path working in a moment)
419+
* The hard path to the change (we'll get that path working [in a moment](#adding-a-new-tag))
407420
* The release date
408421
* A brief list of all the changes (use a `-` for the bullet point if it's fixing a bug, or a `+` for a feature)
409422
* The link to the pull request (pr) (so that the discussion on the change can be easily reviewed) and the changelist (cl)
410423
* The author (and a link to their profile)
411424
* If it's a new contributor, also add them to the [Contributors](#contributors) list below.
412425

413-
Then get a new pull request out for that change to CHANGELOG.
426+
Then get a new pull request out for that change and for the change to the
427+
[module manifest's version number](#updating-the-version-number).
414428

415429
#### Adding a New Tag
416430
To add a new tag:
417431
1. Make sure that you're in a clone of the actual repo and not your own private fork.
418-
2. Make sure that you have checked out `master` and that it's fully up-to-date
419-
3. Run `git tag -a '<version number>'`
420-
4. In the pop-up editor, give a one-line summary of the change (that you possibly already wrote for the CHANGELOG)
421-
5. Save and close the editor
422-
6. Run `git push --tags` to upload the new tag you just created
432+
2. Make sure that you've already merged in the change that updates the module version.
433+
3. Make sure that you have checked out `master` and that it's fully up-to-date
434+
4. Run `git tag -a '<version number>'`
435+
5. In the pop-up editor, just copy the content from the CHANGELOG that you just wrote, but remove
436+
any of the `###` heading blocks since those will be dropped from git as comments instead of
437+
headings.
438+
6. Save and close the editor
439+
7. Run `git push --tags` to upload the new tag you just created
423440

424441
If you want to make sure you get these tags on any other forks/clients, you can run
425442
`git fetch origin --tags` or `git fetch upstream --tags`, or whatever you've named the source to be.
426443

427-
#### Publish a Signed Update to PowerShellGallery
428-
The final steps is getting the module updated on
429-
[PowerShellGallery](https://www.powershellgallery.com/packages/PowerShellForGitHub/)
430-
so that it is easy for users to adopt the changes.
444+
> Doing this makes it possible for users to simply run `git checkout <version number>` to quickly
445+
> set their clone to the state of any previous version.
446+
> It also has the added benefit that GitHub will automatically create a new "Release" in the
447+
> Releases tab of the project for this new version.
448+
449+
#### Running the Release Build
450+
451+
A [YAML definition exists](https://github.com/microsoft/PowerShellForGitHub/blob/master/build/pipelines/azire-pipelines.release.yaml)
452+
that will run the equivalent of the CI build, followed by the necessary steps to sign the module
453+
files and publish the update to PowerShell Gallery. This YAML file can only be run by a Microsoft
454+
maintainer because it accesses internal services to sign the module files with Microsoft's certificate.
431455

432-
The module files should be signed by Microsoft prior to publishing.
433-
Instructions for signing the files and for then publishing the update to PowerShellGallery
434-
can be found in the [internal Microsoft repo for this project](https://microsoft.visualstudio.com/Apps/_git/eng.powershellforgithub).
456+
> **Microsoft Maintainers**: You can access the internal pipeline which can execute the release build
457+
> [here](https://microsoft.visualstudio.com/Apps/_build?definitionId=43898). Simply hit `Queue` to
458+
> get a new module released.
459+
>
460+
> Instructions for updating the `PowerShellGalleryApiKey` secret in the pipeline can be found in the
461+
> [internal Microsoft repo for this project](https://microsoft.visualstudio.com/Apps/_git/eng.powershellforgithub).
435462
436463
----------
437464

azure-pipelines.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Continuous Integration (CI)
3+
# This pipeline validates the module for Static Analysis and Unit Test issues.
4+
#
5+
6+
# ---------------------------------------------------------
7+
# REQUIRED: These variables MUST be set within the pipeline
8+
# * GitHubAccessToken - {secret} The access token with sufficient permissions to modify the
9+
# accounts specified by GitHubOwnerName and GitHubOrganizatioName.
10+
# * GitHubOwnerName - The default "owner" that will be used for tests.
11+
# * GitHubOrganizationName - The default "organization" that will be used for tests.
12+
# ---------------------------------------------------------
13+
14+
trigger:
15+
- master
16+
17+
# Intentionally not having the PR trigger, as we want to kick off PR validation manually after code inspection
18+
#pr:
19+
#- master
20+
21+
jobs:
22+
- job: Windows
23+
pool:
24+
vmImage: 'vs2017-win2016'
25+
steps:
26+
- template: ./templates/run-staticAnalysis.yaml
27+
- template: ./templates/run-unitTests.yaml
28+
29+
- job: Linux
30+
pool:
31+
vmImage: 'ubuntu-16.04'
32+
steps:
33+
- template: ./templates/run-staticAnalysis.yaml
34+
- template: ./templates/run-unitTests.yaml
35+
36+
- job: macOS
37+
pool:
38+
vmImage: 'macOS-10.13'
39+
steps:
40+
- template: ./templates/run-staticAnalysis.yaml
41+
- template: ./templates/run-unitTests.yaml
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# Release
3+
# This pipeline validates the module for Static Analysis and Unit Test issues,
4+
# it then signs it and publishes the updated module to PowerShellGallery.
5+
# This pipeline relies on Microsoft-internal resources to run (for signing the module).
6+
#
7+
8+
# ---------------------------------------------------------
9+
# REQUIRED: These variables MUST be set within the pipeline
10+
# * PowerShellGalleryApiKey - {secret} The API key needed to publish the updated module to PowerShellGallery.
11+
# * GitHubAccessToken - {secret} The access token with sufficient permissions to modify the
12+
# accounts specified by GitHubOwnerName and GitHubOrganizatioName.
13+
# * GitHubOwnerName - The default "owner" that will be used for tests.
14+
# * GitHubOrganizationName - The default "organization" that will be used for tests.
15+
# ---------------------------------------------------------
16+
17+
# Intentionally having no triggers. This pipeline should be kicked-off manually when
18+
# an updated version of the module is ready to be published.
19+
trigger: none
20+
pr: none
21+
22+
variables:
23+
ModuleName: PowerShellForGitHub
24+
ReleasePath: $(BUILD.STAGINGDIRECTORY)\staging\$(ModuleName)
25+
SigningConfigFile: $(BUILD.STAGINGDIRECTORY)\PoShFileSignConfig.xml
26+
27+
jobs:
28+
- job: Validate
29+
pool:
30+
vmImage: 'vs2017-win2016'
31+
steps:
32+
- template: ./templates/run-staticAnalysis.yaml
33+
- template: ./templates/run-unitTests.yaml
34+
35+
- job: Release
36+
dependsOn: Validate
37+
pool:
38+
name: Package ES Lab E
39+
workspace:
40+
clean: outputs
41+
steps:
42+
- checkout: self
43+
clean: true
44+
- template: ./templates/prepare-release-internalOnly.yaml
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#
2+
# This template will sign the module and publish it to PowerShellGallery.
3+
# The signing job relies on Microsoft-internal resources and will not work outside of Microsoft.
4+
# - If you wish to use this yourself, you'll need to replace the signing task (which securely
5+
# accesses a Microsoft-internal certificate) with a task that can sign the files with a certificate
6+
# that you do have access to.
7+
#
8+
9+
#--------------------------------------------------------------------------------------------------
10+
# This template is dependent on the following pipeline variables being configured within the pipeline,
11+
# only one of which MUST be set in the pipeline configuation as opposed to the yaml file.
12+
#
13+
# SET THIS IN THE PIPELINE
14+
# 1. PowerShellGalleryApiKey - The API key needed to publish the updated module to PowerShellGallery.
15+
# It should be configured as a "secret".
16+
#
17+
# OPTIONALLY OVERRIDE THESE IN THE PIPELINE
18+
# 2. ModuleName - The name of this module that is being released.
19+
# 3. ReleasePath - A staging directory that the module will be copied to in order to be
20+
# signed and released from. It is *IMPERATIVE* that the last segment
21+
# in this path is the name of the module.
22+
# 4. SigningApprover - Who has the authority to submit the signing request for the files.
23+
# If left undefined, the signing task will use a preset list of approvers.
24+
# 5. SigningConfigFile - The path to the XML config file that will be used for submitting
25+
# the batched request of module files to be signed.
26+
#--------------------------------------------------------------------------------------------------
27+
28+
steps:
29+
# This must be the first task in the job definition, since it modifies the build environment
30+
# in ways other tasks would not expect (for example, it clears the artifacts directory).
31+
- task: PkgESSetupBuild@10
32+
displayName: Initialize Package ES
33+
inputs:
34+
productName: $(ModuleName)
35+
disableWorkspace: true
36+
env:
37+
XES_DISABLEPROV: true
38+
39+
- powershell: |
40+
if (Test-Path -Path $(ReleasePath) -ErrorAction Ignore)
41+
{
42+
$null = Remove-Item -Path $(ReleasePath) -Recurse -Force
43+
}
44+
45+
$null = Copy-Item -Path ./ -Destination $(ReleasePath) -Recurse -Force
46+
47+
# Remove the ".git" directory which we don't want.
48+
# Doing this via Copy-Item's -Exclude parameter doesn't seem to work right.
49+
$null = Remove-Item -Path (Join-Path -Path $(ReleasePath) -ChildPath '.git') -Recurse -Force
50+
displayName: 'Create copy of module for release signing'
51+
52+
- powershell: |
53+
$localParams = @{
54+
'ModulePath' = "$(ReleasePath)"
55+
'OutPath' = "$(SigningConfigFile)"
56+
'ModuleName' = "$(ModuleName)"
57+
}
58+
59+
# $(SigningApprover) may or may not be set in the build pipeline.
60+
if ($null -ne $SigningApprover)
61+
{
62+
$localParams['Approver'] = $(SigningApprover)
63+
}
64+
65+
./build/scripts/Write-SignConfigXml.ps1 @localParams
66+
displayName: 'Create the sign config xml file'
67+
68+
- task: PkgESCodeSign@10
69+
displayName: Submit module files to Package ES code signing service
70+
env:
71+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
72+
inputs:
73+
signConfigXml: $(SigningConfigFile)
74+
inPathRoot: $(ReleasePath)
75+
outPathRoot: $(ReleasePath)
76+
77+
- task: PublishBuildArtifacts@1
78+
displayName: Publish signed module artifact
79+
inputs:
80+
pathtoPublish: $(ReleasePath)
81+
artifactName: SignedModuleForRelease
82+
83+
- powershell: |
84+
Publish-Module -Path $(ReleasePath) -NuGetApiKey $(PowerShellGalleryApiKey) -Verbose
85+
displayName: 'Publish module to PowerShellGallery'
86+
87+
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
88+
displayName: 'Component Detection'
89+
90+
- task: PkgESLateTasks@10
91+
displayName: Build Finalization
92+
env:
93+
XES_DISABLEPROV: true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# This template contains the necessary jobs to run PSScriptAnalyzer on the repo and
3+
# report the results.
4+
#
5+
6+
steps:
7+
- powershell: |
8+
Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose
9+
displayName: 'Install PSScriptAnalyzer'
10+
11+
- powershell: |
12+
$results = Invoke-ScriptAnalyzer -Path ./ –Recurse
13+
$results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" }
14+
displayName: 'Run Static Code Analysis (PSScriptAnalyzer)'

0 commit comments

Comments
 (0)