-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (98 loc) · 4.47 KB
/
Copy pathPublish-Module.yml
File metadata and controls
106 lines (98 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Publish-Module
on:
workflow_call:
secrets:
PSGALLERY_API_KEY:
description: The API key for the PowerShell Gallery.
required: true
GitHubAppClientId:
description: The client ID of the GitHub App used for repository API calls.
required: true
GitHubAppPrivateKey:
description: The private key of the GitHub App used for repository API calls.
required: true
inputs:
Settings:
type: string
description: The complete settings object.
required: true
permissions: {}
jobs:
Publish-Module:
name: Publish-Module
runs-on: ubuntu-24.04
permissions:
contents: read # Checkout uses github.token.
env:
SETTINGS: ${{ inputs.Settings }}
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout Process-PSModule
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ job.workflow_repository }}
ref: ${{ job.workflow_sha }}
path: _wf
persist-credentials: false
- name: Create GitHub App token
id: App-Token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.GitHubAppClientId }}
private-key: ${{ secrets.GitHubAppPrivateKey }}
repositories: ${{ github.event.repository.name }}
permission-contents: write
permission-pull-requests: write
- name: Publish module
id: publish-module
if: fromJson(inputs.Settings).Publish.Module.Resolution.ReleaseType != 'None'
uses: ./_wf/.github/actions/Publish-PSModule
env:
GH_TOKEN: ${{ steps.App-Token.outputs.token }}
with:
Name: ${{ fromJson(inputs.Settings).Name }}
ModulePath: ${{ fromJson(inputs.Settings).WorkingDirectory }}/.PSModule/module
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
PullRequest: ${{ toJson(fromJson(inputs.Settings).Context.PullRequest) }}
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
WorkingDirectory: ${{ fromJson(inputs.Settings).WorkingDirectory }}
- name: Create GitHub release
id: create-github-release
if: >-
!cancelled() &&
fromJson(inputs.Settings).Publish.Module.Resolution.ReleaseType != 'None' &&
steps.publish-module.outcome == 'success'
uses: ./_wf/.github/actions/Release-PSModule
env:
GH_TOKEN: ${{ steps.App-Token.outputs.token }}
with:
Name: ${{ fromJson(inputs.Settings).Name }}
ModulePath: ${{ fromJson(inputs.Settings).WorkingDirectory }}/.PSModule/module
ArtifactName: module
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
UsePRTitleAsReleaseName: ${{ fromJson(inputs.Settings).Publish.Module.UsePRTitleAsReleaseName }}
UsePRBodyAsReleaseNotes: ${{ fromJson(inputs.Settings).Publish.Module.UsePRBodyAsReleaseNotes }}
UsePRTitleAsNotesHeading: ${{ fromJson(inputs.Settings).Publish.Module.UsePRTitleAsNotesHeading }}
ReleaseTag: ${{ fromJson(inputs.Settings).Publish.Module.Resolution.FullVersion }}
PullRequest: ${{ toJson(fromJson(inputs.Settings).Context.PullRequest) }}
CommitSha: ${{ fromJson(inputs.Settings).Context.CommitSha }}
WorkingDirectory: ${{ fromJson(inputs.Settings).WorkingDirectory }}
- name: Cleanup prereleases
if: >-
always() && !cancelled() &&
fromJson(inputs.Settings).Publish.Module.Resolution.ReleaseType != 'Prerelease' &&
(fromJson(inputs.Settings).Publish.Module.Resolution.ReleaseType == 'None' ||
(steps.publish-module.outcome == 'success' &&
steps.create-github-release.outcome == 'success'))
uses: ./_wf/.github/actions/Cleanup-PSModulePrereleases
env:
GH_TOKEN: ${{ steps.App-Token.outputs.token }}
with:
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
AutoCleanup: ${{ fromJson(inputs.Settings).Publish.Module.AutoCleanup }}
ReleaseTag: ${{ steps.create-github-release.outputs.ReleaseTag }}
PullRequest: ${{ toJson(fromJson(inputs.Settings).Context.PullRequest) }}
WorkingDirectory: ${{ fromJson(inputs.Settings).WorkingDirectory }}