Documentation
¶
Overview ¶
Package publish cuts the release a merged Release merge request describes.
The sequence is fixed by go/forge's contract and by spec 0001 D5:
- find the merged Release merge request
- resolve the commit that ACTUALLY LANDED on the target branch
- read the changelog at that commit — which names the version
- create the annotated tag there, and push it
- create the release object on that tag
Steps 4 and 5 are in that order because forge.CreateRelease refuses a tag that does not exist. That refusal is deliberate: given a missing tag a forge creates one from whatever ref it was handed, turning the call into a tagging operation performed with whichever credential is to hand.
Index ¶
Constants ¶
const ChangelogFile = "CHANGELOG.md"
ChangelogFile is the file a release is described by.
Variables ¶
var ( // ErrMissingField reports a required input absent from a [Request]. ErrMissingField = errors.New("publish: missing required field") // ErrNothingMerged reports no merged release merge request on the release // branch. Ordinary: `publish` runs after every merge to the target, and // most of those are not releases. ErrNothingMerged = errors.New("publish: nothing merged to release") )
Functions ¶
This section is empty.
Types ¶
type Outcome ¶
type Outcome struct {
Version string
Tag string
Commit string
// Number is the merged merge request this release came from.
Number int
// Tagged is false when the tag was already there on the same commit.
Tagged bool
// Released is false when the release already existed, or when the forge
// has no release object.
Released bool
// ReleasesUnsupported reports a forge with no release object — a permanent
// answer about the platform, not a failure.
ReleasesUnsupported bool
// SkippedHeadings are level-two headings in the changelog that are not
// releases, passed over to find the one that is.
//
// Reported rather than swallowed. Reading past them is what keeps an
// unparseable changelog from making a repository permanently unreleasable,
// but a changelog drifting from the shape colophon writes should be VISIBLE
// in the job log rather than silently tolerated.
SkippedHeadings []string
// NotHonoured names what the forge could not apply. GitLab models neither
// draft nor prerelease, and reports that rather than staying silent.
NotHonoured string
}
Outcome reports what happened. Every field is what it DID, not what it intended: a re-run reports false for work a previous run already completed.
type Publisher ¶
type Publisher interface {
CreateRelease(ctx context.Context, owner, repo string, draft forge.ReleaseDraft) (forge.Release, error)
}
Publisher creates the release object.
OPTIONAL, and nil is a legitimate value: Bitbucket Cloud has no release object at all, so on that platform colophon tags and stops. The tag is the part that matters; the platform genuinely has nowhere to put the rest.
Satisfied by forge.ReleasePublisher.
type Releaser ¶
type Releaser struct {
// contains filtered or unexported fields
}
Publisher orchestrates the release.
type Request ¶
type Request struct {
Owner string
Repo string
// Remote is the clone location, and Target the branch the release landed
// on. Branch is the release branch whose merge request is being published.
Remote string
Target string
Branch string
Author tree.Author
}
Request is one release.
type Resolver ¶
type Resolver interface {
FindLastMerged(ctx context.Context, owner, repo, sourceBranch string) (forge.PullRequest, error)
ResolveMergedCommit(ctx context.Context, owner, repo string, number int) (string, error)
}
Resolver is what `publish` needs to learn what landed, and nothing more. It cannot open, update or close anything.
Satisfied by forge.PullRequests.