-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (146 loc) · 5.49 KB
/
release.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: PCO-Release - Release Automation
on:
workflow_call:
inputs:
pr-number:
description: "The PR number that triggered the release"
required: true
type: number
install-command:
description: "The script command to use to install the package's dependencies"
required: false
type: string
default: "yarn install --check-files"
build-command:
description: "The script command to use to build the package"
required: false
type: string
default: "yarn build"
test-command:
description: "The script command to use to test the package"
required: false
type: string
default: "yarn test"
publish-command:
description: "The command to run to publish a release version of the package to NPM"
required: false
type: string
default: "npm publish"
cache:
description: "Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm, or '' for no caching."
required: false
type: string
default: "yarn"
build-directory:
description: "The build output directory"
required: false
type: string
default: "dist"
only:
description: "Only run on specific repos. This is a comma separated list of repo names (ie 'people,services,groups')"
required: false
type: string
default: ""
include:
description: "repos to include without checking. Comma separated list"
required: false
type: string
default: ""
exclude:
description: "repos to exclude without checking. Comma separated list"
required: false
type: string
default: ""
upgrade-commands:
description: "JSON string of repo names and their specific upgrade commands. Useful for monorepos where the package.json does not exist in the root directory."
required: false
type: string
default: "{}"
package-json-path:
description: "The path to the package.json file to version."
required: false
type: string
default: "package.json"
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Create Release
uses: planningcenter/pco-release-action/create-release-on-merge@v1
with:
package_json_path: ${{ inputs.package-json-path }}
outputs:
release-tag: v${{ env.version }}
publish-to-npm:
needs: create-release
uses: planningcenter/pco-release-action/.github/workflows/publish.yml@v1
secrets: inherit
with:
install-command: ${{ inputs.install-command }}
build-command: ${{ inputs.build-command }}
test-command: ${{ inputs.test-command }}
publish-command: ${{ inputs.publish-command }}
cache: ${{ inputs.cache }}
build-directory: ${{ inputs.build-directory }}
ref: ${{ needs.create-release.outputs.release-tag }}
prerelease: false
deploy-to-consumers:
needs: [create-release, publish-to-npm]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
PR_NUMBER: ${{ inputs.pr-number }}
steps:
- name: Push to Consumers
id: push-to-consumers
uses: planningcenter/pco-release-action/deploy@v1
with:
app-id: ${{ secrets.PCO_DEPENDENCIES_APP_ID }}
private-key: ${{ secrets.PCO_DEPENDENCIES_PRIVATE_KEY }}
ref: ${{ needs.create-release.outputs.release-tag }}
change-method: "pr"
only: ${{ inputs.only }}
exclude: ${{ inputs.exclude }}
include: ${{ inputs.include }}
upgrade-commands: ${{ inputs.upgrade-commands }}
allow-major: false
package-json-path: ${{ inputs.package-json-path }}
- name: Post results to original PR
uses: actions/github-script@v7
env:
ACTOR: ${{ github.actor }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = JSON.parse(process.env.results_json);
const body = `## Release Automation Results
Triggered by: @${process.env.ACTOR}
${results.successful_repos.length > 0 ? "### PRs created" : ""}
${results.successful_repos.map(repo => "- [" + repo.name + "](" + repo.pr_url + ")").join("\n")}
${results.failed_repos.length > 0 ? "### PRs failed" : ""}
${results.failed_repos.map(repo => "- " + repo.name + ": " + repo.message).join("\n")}
### Next steps
Run the following command to approve all the PRs:
\`\`\`
${results.successful_repos.map(repo => "gh pr review " + repo.pr_number + " --repo=planningcenter/" + repo.name + " -a").join("\n")}
\`\`\`
### If you need to revert
- Go to the actions tab
- Click \`Revert\` on the left hand actions list
- Click to the \`Run workflow\` button on the right
- enter the last successful version and click \`Run workflow\`
`
github.rest.issues.createComment({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
if (results.failed_repos.length > 0) {
throw new Error("Some PRs failed to create");
}