diff --git a/dist/breaking-change.md b/dist/breaking-change.md index 600ca01..df5fac2 100644 --- a/dist/breaking-change.md +++ b/dist/breaking-change.md @@ -1,9 +1,16 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`breaking-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-breaking-change) proposal to the Standard, this means that an old version of `publiccode.yml` won't be compatible with the new version. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`breaking-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-breaking-change) proposal to the Standard. This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} +{{^release_candidate}} Breaking changes can be released with a new major version at most once every two years, provided the current version of the Standard has been deprecating the object of this proposal for at least 6 months. +{{/release_candidate}} Example of breaking changes are removal of keys or changes to key types. The next eligible voting round will take place on **{{ next_vote_date }}** diff --git a/dist/bugfix-change.md b/dist/bugfix-change.md index 066fa5f..8d093bf 100644 --- a/dist/bugfix-change.md +++ b/dist/bugfix-change.md @@ -1,7 +1,12 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`bugfix-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-bugfix-change), this means that this change won't break any compatibility with the old versions of the Standard. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`bugfix-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-bugfix-change). This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} Example of bugfix changes are typo fixes. diff --git a/dist/deprecation-change.md b/dist/deprecation-change.md index 2555159..a1b1033 100644 --- a/dist/deprecation-change.md +++ b/dist/deprecation-change.md @@ -1,7 +1,12 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`deprecation-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-deprecation), this means that this change won't break any compatibility with the old versions of the Standard, and it will be possibile to make the definitive change 6 months after the deprecation with a new major release. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`deprecation-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-deprecation). This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} The next eligible voting round will take place on **{{ next_vote_date }}** diff --git a/dist/index.js b/dist/index.js index 4d61bc0..7181be2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8923,7 +8923,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.removeLabel = exports.addLabels = exports.setLabels = exports.commentToIssue = exports.reactToComment = exports.isChair = exports.isMaintainer = exports.inTeam = exports.getCommandsFromComment = void 0; +exports.removeLabel = exports.addLabels = exports.setLabels = exports.commentToIssue = exports.reactToComment = exports.hasLabel = exports.isChair = exports.isMaintainer = exports.inTeam = exports.getCommandsFromComment = void 0; const fs_1 = __nccwpck_require__(7147); const mustache_1 = __importDefault(__nccwpck_require__(8272)); const config_1 = __nccwpck_require__(6373); @@ -8956,6 +8956,12 @@ function isChair(org, username) { }); } exports.isChair = isChair; +function hasLabel(context, name) { + var _a, _b; + const labels = ((_b = (_a = context.payload.issue) === null || _a === void 0 ? void 0 : _a.labels) !== null && _b !== void 0 ? _b : []); + return labels.some(label => label.name === name); +} +exports.hasLabel = hasLabel; function reactToComment(context) { var _a; return __awaiter(this, void 0, void 0, function* () { @@ -8996,6 +9002,7 @@ function toMustacheView(context) { steering_committee_team: config_1.STEERING_COMMITTEE_TEAM, comment_author_username: (_c = (_b = (_a = context.payload.comment) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.login) !== null && _c !== void 0 ? _c : '', next_vote_date: getNextVoteDate(), + release_candidate: hasLabel(context, 'v1'), }; } function commentToIssue(context, template, additionalVariables) { @@ -9384,6 +9391,7 @@ function run(context) { // eslint-disable-next-line prefer-template,no-path-concat const template = (0, fs_1.readFileSync)(__nccwpck_require__.ab + "vote-end.md", 'utf8'); (0, bot_1.reactToComment)(context); + const isReleaseCandidate = (0, bot_1.hasLabel)(context, 'v1'); const { owner, repo, number } = context.issue; const comments = yield octokit_1.default.paginate('GET /repos/:owner/:repo/issues/:issue_number/comments', { owner, repo, issue_number: number }); const voteComment = getBotComment(comments, ''); @@ -9420,7 +9428,13 @@ function run(context) { const voteResults = processResults(thumbsUps.map(t => t.user.login), thumbsDowns.map(t => t.user.login), !isAdditionalPeriod, approvingMember); switch (+voteResults) { case VoteResult.Approved: - resultMessage = ` + resultMessage = isReleaseCandidate + ? ` +**Proposal approved** :+1: + +This proposal will be merged into the \`1.0-rc\` branch and released later as part of v1.0. + ` + : ` **Proposal approved** :+1: This proposal is now ready to be merged and get released with a new version of the standard. diff --git a/dist/minor-change.md b/dist/minor-change.md index 008da21..590e9c3 100644 --- a/dist/minor-change.md +++ b/dist/minor-change.md @@ -1,7 +1,12 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`minor-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-minor-change), this means that old versions of `publiccode.yml` will still be valid with this change. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`minor-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-minor-change). This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} Example of minor changes are additions of new keys or making keys optional. diff --git a/dist/vote-start.md b/dist/vote-start.md index 7d87edb..996913b 100644 --- a/dist/vote-start.md +++ b/dist/vote-start.md @@ -7,4 +7,8 @@ The polls will stay open for {{ vote_period_days }} days, until **{{ vote_end_da Leave a :+1: (thumbs up) **on this comment** to accept the proposal or a :-1: (thumbs down) to reject it. +{{#release_candidate}} +This proposal targets **v1.0**. If approved it will be merged into the `1.0-rc` branch and released later as part of v1.0, not immediately. + +{{/release_candidate}} cc @{{{ steering_committee_team }}} diff --git a/src/bot.test.ts b/src/bot.test.ts new file mode 100644 index 0000000..3110ae0 --- /dev/null +++ b/src/bot.test.ts @@ -0,0 +1,24 @@ +import { Context } from '@actions/github/lib/context'; + +import { hasLabel } from './bot'; + +function contextWithLabels(labels: unknown): Context { + return { payload: { issue: { labels } } } as unknown as Context; +} + +test('hasLabel returns true when the label is present', () => { + const context = contextWithLabels([{ name: 'v1' }, { name: 'vote-start' }]); + + expect(hasLabel(context, 'v1')).toBe(true); +}); + +test('hasLabel returns false when the label is absent', () => { + const context = contextWithLabels([{ name: 'vote-start' }]); + + expect(hasLabel(context, 'v1')).toBe(false); +}); + +test('hasLabel returns false when there are no labels', () => { + expect(hasLabel(contextWithLabels([]), 'v1')).toBe(false); + expect(hasLabel({ payload: {} } as unknown as Context, 'v1')).toBe(false); +}); diff --git a/src/bot.ts b/src/bot.ts index 5b59ac9..9df106d 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -21,6 +21,7 @@ interface TemplateVariables { bot_username: string; comment_author_username: string; next_vote_date: string; + release_candidate: boolean; } export interface Command { @@ -51,6 +52,12 @@ export async function isChair(org: string, username: string) { return inTeam(org, username, 'chair'); } +export function hasLabel(context: Context, name: LabelName): boolean { + const labels = (context.payload.issue?.labels ?? []) as Array<{ name?: string }>; + + return labels.some(label => label.name === name); +} + export async function reactToComment(context: Context) { const { owner: org, repo } = context.repo; @@ -94,6 +101,7 @@ function toMustacheView(context: Context): TemplateVariables { steering_committee_team: STEERING_COMMITTEE_TEAM, comment_author_username: context.payload.comment?.user?.login ?? '', next_vote_date: getNextVoteDate(), + release_candidate: hasLabel(context, 'v1'), }; } diff --git a/src/commands/voteEnd.ts b/src/commands/voteEnd.ts index 16e869f..de01b61 100644 --- a/src/commands/voteEnd.ts +++ b/src/commands/voteEnd.ts @@ -3,7 +3,7 @@ import { Context } from '@actions/github/lib/context'; import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types'; import { BOT_USERNAME, MAINTAINERS_TEAM } from '../config'; import { - reactToComment, commentToIssue, addLabels, removeLabel, + reactToComment, commentToIssue, addLabels, removeLabel, hasLabel, } from '../bot'; import { LabelName } from '../labels'; import octokit from '../octokit'; @@ -100,6 +100,8 @@ export default async function run(context: Context) { reactToComment(context); + const isReleaseCandidate = hasLabel(context, 'v1'); + const { owner, repo, number } = context.issue; const comments = await octokit.paginate( @@ -159,7 +161,13 @@ export default async function run(context: Context) { switch (+voteResults) { case VoteResult.Approved: - resultMessage = ` + resultMessage = isReleaseCandidate + ? ` +**Proposal approved** :+1: + +This proposal will be merged into the \`1.0-rc\` branch and released later as part of v1.0. + ` + : ` **Proposal approved** :+1: This proposal is now ready to be merged and get released with a new version of the standard. diff --git a/src/labels.ts b/src/labels.ts index ecbeff6..f9d980b 100644 --- a/src/labels.ts +++ b/src/labels.ts @@ -4,6 +4,7 @@ export type LabelName = | 'standard-deprecation' | 'standard-minor-change' | 'standard-national-section' + | 'v1' | 'vote-additional-period' | 'vote-approved' | 'vote-draft' diff --git a/src/templates/breaking-change.md b/src/templates/breaking-change.md index 600ca01..df5fac2 100644 --- a/src/templates/breaking-change.md +++ b/src/templates/breaking-change.md @@ -1,9 +1,16 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`breaking-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-breaking-change) proposal to the Standard, this means that an old version of `publiccode.yml` won't be compatible with the new version. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`breaking-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-breaking-change) proposal to the Standard. This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} +{{^release_candidate}} Breaking changes can be released with a new major version at most once every two years, provided the current version of the Standard has been deprecating the object of this proposal for at least 6 months. +{{/release_candidate}} Example of breaking changes are removal of keys or changes to key types. The next eligible voting round will take place on **{{ next_vote_date }}** diff --git a/src/templates/bugfix-change.md b/src/templates/bugfix-change.md index 066fa5f..8d093bf 100644 --- a/src/templates/bugfix-change.md +++ b/src/templates/bugfix-change.md @@ -1,7 +1,12 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`bugfix-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-bugfix-change), this means that this change won't break any compatibility with the old versions of the Standard. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`bugfix-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-bugfix-change). This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} Example of bugfix changes are typo fixes. diff --git a/src/templates/deprecation-change.md b/src/templates/deprecation-change.md index 2555159..a1b1033 100644 --- a/src/templates/deprecation-change.md +++ b/src/templates/deprecation-change.md @@ -1,7 +1,12 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`deprecation-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-deprecation), this means that this change won't break any compatibility with the old versions of the Standard, and it will be possibile to make the definitive change 6 months after the deprecation with a new major release. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`deprecation-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-deprecation). This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} The next eligible voting round will take place on **{{ next_vote_date }}** diff --git a/src/templates/minor-change.md b/src/templates/minor-change.md index 008da21..590e9c3 100644 --- a/src/templates/minor-change.md +++ b/src/templates/minor-change.md @@ -1,7 +1,12 @@ Thanks for your contribution :pray: +{{^release_candidate}} This is now marked as a [`minor-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-minor-change), this means that old versions of `publiccode.yml` will still be valid with this change. +{{/release_candidate}} +{{#release_candidate}} +This is now marked as a [`minor-change` proposal to the standard](https://github.com/publiccodeyml/publiccode.yml/labels/standard-minor-change). This targets the upcoming **v1.0** on the `1.0-rc` branch. +{{/release_candidate}} Example of minor changes are additions of new keys or making keys optional. diff --git a/src/templates/vote-start.md b/src/templates/vote-start.md index 7d87edb..996913b 100644 --- a/src/templates/vote-start.md +++ b/src/templates/vote-start.md @@ -7,4 +7,8 @@ The polls will stay open for {{ vote_period_days }} days, until **{{ vote_end_da Leave a :+1: (thumbs up) **on this comment** to accept the proposal or a :-1: (thumbs down) to reject it. +{{#release_candidate}} +This proposal targets **v1.0**. If approved it will be merged into the `1.0-rc` branch and released later as part of v1.0, not immediately. + +{{/release_candidate}} cc @{{{ steering_committee_team }}}