Skip to content

Commit

Permalink
Merge pull request #76 from theohbrothers/fix/remove-creation-of-.git…
Browse files Browse the repository at this point in the history
…lab-ci.yml.ps1-on-init

Fix: Remove creation of `.gitlab-ci.yml.ps1` on `-Init`
  • Loading branch information
leojonathanoh authored Mar 22, 2023
2 parents 6f01d8d + a8856ca commit 9104257
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 112 deletions.
33 changes: 27 additions & 6 deletions .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
test-powershell-7-2:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/powershell:7.2.0-preview.4-ubuntu-18.04
image: mcr.microsoft.com/powershell:7.2.2-ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Powershell version
Expand All @@ -104,7 +104,7 @@ jobs:
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'
update-draft-release:
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-1, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2]
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-2, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2, test-publish-to-psgallery]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
Expand All @@ -116,8 +116,29 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test-publish-to-psgallery:
if: github.ref == 'refs/heads/master' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Publish (dry run)
run: |
set -e
# Generate the new module manifest
MODULE_VERSION=987.0.0
MODULE_VERSION=${MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Build.ps1
# Publish the module
MODULE_NAME=$(basename $(pwd))
NUGET_API_KEY=xxx MODULE_VERSION=${MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery -DryRun
publish-to-psgallery:
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-1, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2]
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-2, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2, test-publish-to-psgallery]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand All @@ -141,13 +162,13 @@ jobs:
# Generate the new module manifest
MODULE_NAME=$(basename $(pwd))
MODULE_VERSION=${MODULE_VERSION} pwsh -Command "build/PSModulePublisher/src/module/Generate-ModuleManifest.ps1 -DefinitionFile build/definitions/modulemanifest/definition.ps1 -Path src/$MODULE_NAME/$MODULE_NAME.psd1"
MODULE_VERSION=${MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Build.ps1
# Publish the module
NUGET_API_KEY=${NUGET_API_KEY} MODULE_VERSION=${MODULE_VERSION} pwsh -Command "build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery"
NUGET_API_KEY=${NUGET_API_KEY} MODULE_VERSION=${MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery
publish-draft-release:
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-1, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2, publish-to-psgallery]
needs: [publish-to-psgallery]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down
20 changes: 10 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"id": "NUGET_API_KEY",
"description": "NUGET_API_KEY?",
"type": "promptString",
"default": "",
"default": "xxx",
},
{
"id": "MODULE_VERSION",
Expand All @@ -32,25 +32,25 @@
{
"label": "Build: Generate module manifest",
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/module/Generate-ModuleManifest.ps1 -DefinitionFile build/definitions/modulemanifest/definition.ps1 -Path src/$MODULE_NAME/$MODULE_NAME.psd1\"",
"group": "build"
},
{
"label": "Build: Test module manifest",
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/module/Test-ModuleManifest.ps1 -Path src/$MODULE_NAME/$MODULE_NAME.psd1\"",
"command": "MODULE_VERSION=${input:MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Build.ps1",
"group": "build"
},
{
"label": "Publish module (dry run)",
"dependsOn":[
"Build: Generate module manifest"
],
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery -DryRun\"",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery -DryRun",
"group": "build"
},
{
"label": "Publish module",
"dependsOn":[
"Build: Generate module manifest"
],
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery\"",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery",
"group": "build"
},

Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ If prompted to trust the repository, hit `Y` and `enter`.
│ │ ├── FILES.ps1
│ │ └── VARIANTS.ps1
│ └── templates
│ ├── .gitlab-ci.ps1
│ ├── Dockerfile.ps1
│ └── README.md.ps1
```
Expand All @@ -88,7 +87,6 @@ If prompted to trust the repository, hit `Y` and `enter`.
│ │ ├── FILES.ps1
│ │ └── VARIANTS.ps1
│ └── templates
│ ├── .gitlab-ci.ps1
│ ├── Dockerfile.ps1
│ └── README.md.ps1
├── README.md
Expand Down Expand Up @@ -356,11 +354,10 @@ To specify that only certain components be processed, independent of the `tag` p
To generate files other than variant build contexts in `/variants`, define them in `FILES.ps1`.
Suppose we want to generate `.gitlab-ci.yml` and `README.md`:
Suppose we want to generate `README.md`:
```powershell
$FILES = @(
'.gitlab-ci.yml'
'README.md'
)
```
Expand All @@ -371,15 +368,13 @@ Then, create their templates in the `/generate/templates` directory:
.
├── generate
│ └── templates
│ ├── gitlab-ci.yml.ps1 # gitlab-ci.yml template
│ └── README.md.ps1 # README.md template
```
The generation results in two files, relative to the base of the project:
```sh
.
├── .gitlab-ci.yml
└── .README.md
```
Expand Down Expand Up @@ -529,8 +524,6 @@ VERBOSE: Processing template file: /path/to/my-repo/generate/templates/Dockerfil
Generating build context of variant 'my-cool-variant': /path/to/my-repo/variants/my-cool-variant
VERBOSE: Generating build context file: /path/to/my-repo/variants/my-cool-variant/Dockerfile
VERBOSE: Processing template file: /path/to/my-repo/generate/templates/Dockerfile.ps1
Generating repository file: /path/to/my-repo/.gitlab-ci.yml
VERBOSE: Processing template file: /path/to/my-repo/generate/templates/.gitlab-ci.yml.ps1
Generating repository file: /path/to/my-repo/README.md
VERBOSE: Processing template file: /path/to/my-repo/generate/templates/README.md.ps1
```
14 changes: 7 additions & 7 deletions build/definitions/modulemanifest/definition.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
AliasesToExport = @()
# DscResourcesToExport = @()
# ModuleList = @()
FileList = @(
& {
Set-Location $PSScriptRoot/../../../src/Generate-DockerImageVariants/
Get-ChildItem -File -Recurse -Force | Resolve-Path -Relative
Set-Location -
}
)
# FileList = @(
# & {
# Set-Location $PSScriptRoot/../../../src/Generate-DockerImageVariants/
# Get-ChildItem -File -Recurse -Force | Resolve-Path -Relative
# Set-Location -
# }
# )
PrivateData = @{
# PSData = @{ # Properties within PSData will be correctly added to the manifest via Update-ModuleManifest without the PSData key. Leave the key commented out.
Tags = @(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Describe 'Generate-DockerImageVariants' -Tag 'Integration' {
# Expected templates files
$testProjectGenerateTemplatesDockerfile = Join-Path $testProjectGenerateTemplatesDir 'Dockerfile.ps1'
$testProjectGenerateTemplatesReadmeMd = Join-Path $testProjectGenerateTemplatesDir 'README.md.ps1'
$testProjectGenerateTemplatesGitlabCiYml = Join-Path $testProjectGenerateTemplatesDir '.gitlab-ci.yml.ps1'

Generate-DockerImageVariants -Init -ProjectPath $testProjectDir 6>&1 > $null

Expand All @@ -39,7 +38,6 @@ Describe 'Generate-DockerImageVariants' -Tag 'Integration' {

$testProjectGenerateTemplatesDockerfile | Get-Item -Force | Should -BeOfType [System.IO.FileInfo]
$testProjectGenerateTemplatesReadmeMd | Get-Item -Force | Should -BeOfType [System.IO.FileInfo]
$testProjectGenerateTemplatesGitlabCiYml | Get-Item -Force | Should -BeOfType [System.IO.FileInfo]

# Cleanup
Get-Item $testProjectDir | Remove-Item -Recurse -Force
Expand All @@ -62,7 +60,6 @@ Describe 'Generate-DockerImageVariants' -Tag 'Integration' {
# Expected templates files
$testProjectGenerateTemplatesDockerfile = Join-Path $testProjectGenerateTemplatesDir 'Dockerfile.ps1'
$testProjectGenerateTemplatesReadmeMd = Join-Path $testProjectGenerateTemplatesDir 'README.md.ps1'
$testProjectGenerateTemplatesGitlabCiYml = Join-Path $testProjectGenerateTemplatesDir '.gitlab-ci.yml.ps1'

# Create all folders, one definition file, one template file
$testProjectGenerateDefinitionsFiles,
Expand All @@ -76,7 +73,7 @@ Describe 'Generate-DockerImageVariants' -Tag 'Integration' {
@( $infoStream | ? { $_.MessageData.Message -cmatch '^Not creating definition file' }).Count |Should -Be 1
@( $infoStream | ? { $_.MessageData.Message -cmatch '^Creating definition file' }).Count | Should -Be 1
@( $infoStream | ? { $_.MessageData.Message -cmatch '^Not creating template file' }).Count | Should -Be 1
@( $infoStream | ? { $_.MessageData.Message -cmatch '^Creating template file' }).Count | Should -Be 2
@( $infoStream | ? { $_.MessageData.Message -cmatch '^Creating template file' }).Count | Should -Be 1

# Cleanup
Get-Item $testProjectDir | Remove-Item -Recurse -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ FileList = './Generate-DockerImageVariants.Integration.Tests.ps1',
'./public/Generate-DockerImageVariants.Tests.ps1',
'./samples/generate/definitions/FILES.ps1',
'./samples/generate/definitions/VARIANTS.ps1',
'./samples/generate/templates/.gitlab-ci.yml.ps1',
'./samples/generate/templates/Dockerfile.ps1',
'./samples/generate/templates/README.md.ps1',
'./helper/New-Clone.ps1', './helper/Validate-Object.ps1',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
$FILES = @(
'.gitlab-ci.yml'
'README.md'
)

This file was deleted.

0 comments on commit 9104257

Please sign in to comment.