Repository navigation
195 lines (195 loc) · 8.92 KB
/
Copy pathrelease.yml
File metadata and controls
195 lines (195 loc) · 8.92 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Publish a Composer library after preparation and successful validation of the same
# source commit. Both Node.js and Composer callers follow prepare, validate and release.
#
# ### Release model
#
# Composer derives library versions from Git tags. Keep `version` out of
# `composer.json`. Preparation plans the tag without changing source files, creating
# Git tags or dispatching another run. Validation checks that same commit. Publication
# verifies the source and tag again, then creates the GitHub release. GitHub provides
# source archives; Packagist discovers tags through its configured update integration.
#
# Use `ci-github-publish` for version planning, tag verification, release notes and
# publication. A Composer source release needs no package artifact, version commit,
# GitHub App or `CHANGELOG.md`. Repository and tag rules still apply.
#
# ### Complete caller workflow
#
# Pin the same reviewed PHP workflow commit throughout the caller. Validation is
# independent: use your own job or the shared CI workflow. Optional distribution
# checks belong to validation; publication does not build, install dependencies or
# run tests. Gate validation on preparation being ready, and publication on both jobs.
# Pass the prepared tag unchanged. Every stage must use the same source commit.
#
# ```yaml
# name: Release
# on:
# workflow_dispatch:
# inputs:
# force:
# description: Release even without relevant changes
# type: boolean
# default: false
# schedule:
# - cron: "37 7 * * 1"
# permissions: {}
# concurrency:
# group: composer-release
# cancel-in-progress: false
# jobs:
# prepare:
# uses: hoverkraft-tech/ci-github-php/.github/workflows/prepare-package-release.yml@<commit-sha>
# permissions:
# contents: read
# pull-requests: read
# with:
# force: ${{ github.event_name == 'workflow_dispatch' && inputs.force || false }}
# release-config: &release-config |
# tag-template: v$RESOLVED_VERSION
# tag-prefix: v
# validate:
# needs: prepare
# if: needs.prepare.outputs.status == 'ready'
# uses: hoverkraft-tech/ci-github-php/.github/workflows/continuous-integration.yml@<commit-sha>
# permissions:
# contents: read
# id-token: write
# with:
# package: "true"
# release:
# needs: [prepare, validate]
# uses: hoverkraft-tech/ci-github-php/.github/workflows/release.yml@<commit-sha>
# permissions:
# contents: write
# pull-requests: read
# with:
# tag: ${{ needs.prepare.outputs.tag }}
# release-config: *release-config
# secrets:
# changelog-summary: ${{ secrets.CHANGELOG_SUMMARY }}
# ```
#
# ### No changes, force, and retries
#
# Preparation returns `no-changes` when there is nothing to release. Both validation
# and publication are skipped. `ready` supplies the planned tag and allows validation;
# `released` means an explicitly retried tag is already published, so no work is needed.
#
# On a manual default-branch run, `force: true` asks the shared planner for a release
# even without changes. The configured version rules determine the next version;
# force preserves that planned identity. Existing tag collisions fail. Schedules
# ignore force. Tags are never moved.
#
# Rerun a failed workflow to retry publication. To recover an older version after the
# default branch advances, dispatch against its existing tag. Tag retries bypass version
# planning and keep the original tag; force is ignored. The shared verifier requires
# that tag to exist and match this run's source commit. Draft releases can be resumed.
#
# The caller's concurrency group serializes the complete journey. The reusable
# preparation and publication workflows use separate groups; keep caller names distinct
# and disable cancellation. Validation failure prevents tag or release creation.
#
# ### Release configuration and summaries
#
# Use partial YAML or JSON `release-config`, or `.github/release-config.yml`, as
# supported by `ci-github-publish`. Shared defaults are inherited, repository settings
# override them, and input settings take precedence. Pass identical configuration to
# preparation and publication. Composer tags must be stable `X.Y.Z` or `vX.Y.Z` versions;
# match the repository's existing tag prefix.
#
# `changelog-summary` accepts the public JSON configuration supported by
# `ci-github-publish/actions/release/create`, including its summary providers.
# Use the optional secret for configuration containing credentials; it takes precedence
# over the input. Omit both for generated release notes without AI.
#
# See the [ci-github-publish release guide](https://github.com/hoverkraft-tech/ci-github-publish/blob/main/.github/workflows/release.md)
# for configuration and summary details. Register the repository with Packagist and
# configure its GitHub integration separately.
#
# ### Prepare release labels
#
# Keep a separate `.github/workflows/prepare-release.yml` caller for the shared
# `ci-github-publish/.github/workflows/prepare-release.yml`. It applies release labels
# from Conventional Commit pull request titles. Package release preparation uses
# `prepare-package-release.yml` and runs on manual or scheduled release events.
# The label workflow uses pull request events `opened`, `reopened`, `synchronize`,
# and `edited`, with `contents: read` and `pull-requests: write` permissions.
# The shared label workflow owns its concurrency group.
name: Release Composer Package
on:
workflow_call:
inputs:
tag:
description: Composer version tag returned by prepare-package-release. Require successful validation of this source commit with needs before publication.
type: string
required: true
release-config:
description: Partial YAML or JSON configuration forwarded to ci-github-publish/actions/release/create. Use the same configuration as preparation.
type: string
default: ""
changelog-summary:
description: Optional JSON summary configuration forwarded to ci-github-publish/actions/release/create. Supports its providers and options. Use the secret for credentials.
type: string
default: ""
secrets:
changelog-summary:
description: Complete optional JSON summary configuration, including provider credentials. Overrides the input.
required: false
permissions: {}
concurrency:
group: php-release-publish-${{ github.repository }}
cancel-in-progress: false
jobs:
verify:
name: Verify Composer release source
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
outputs:
published: ${{ fromJSON(steps.verify.outputs.releases)[0].published }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: source
name: Validate Composer manifest and release context
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
TAG: ${{ inputs.tag }}
with:
script: |-
const defaultRef = 'refs/heads/' + context.payload.repository.default_branch;
const retry = context.eventName === 'workflow_dispatch' && context.ref.startsWith('refs/tags/');
if (!['workflow_dispatch', 'schedule'].includes(context.eventName) || (context.ref !== defaultRef && !retry)) {
throw new Error('Publication requires a manual or scheduled default-branch run, or a manual tag retry.');
}
const tag = process.env.TAG;
if (!/^(v?)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(tag) || (retry && context.ref !== 'refs/tags/' + tag)) {
throw new Error('Use the prepared stable Composer tag, matching the retry tag when applicable.');
}
const manifest = JSON.parse(require('node:fs').readFileSync('composer.json', 'utf8'));
if (typeof manifest.name !== 'string' || !/^[a-z0-9][a-z0-9_.-]*\/[a-z0-9][a-z0-9_.-]*$/.test(manifest.name) || manifest.version !== undefined) {
throw new Error('Declare a public Composer package without a hardcoded version.');
}
- id: verify
uses: hoverkraft-tech/ci-github-publish/actions/release/verify@bf24f894f60a3def62a8750f3964d05acb052c11 # 3.1.2
with:
tags: ${{ format('["{0}"]', inputs.tag) }}
require-tags: ${{ startsWith(github.ref, 'refs/tags/') }}
publish:
name: Publish GitHub release
needs: verify
if: needs.verify.outputs.published != 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: write
pull-requests: read
steps:
- uses: hoverkraft-tech/ci-github-publish/actions/release/create@bf24f894f60a3def62a8750f3964d05acb052c11 # 3.1.2
with:
tag: ${{ inputs.tag }}
target-ref: ${{ github.sha }}
config-overrides: ${{ inputs.release-config }}
changelog-summary: ${{ secrets.changelog-summary || inputs.changelog-summary }}