@afoures/auto-release 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,7 @@ import { find_nearest_config } from "../config.mjs";
5
5
  import { find_change_files } from "../change-file.mjs";
6
6
  import { diff, reset } from "../utils/git.mjs";
7
7
  import { compute_current_version } from "../utils/version.mjs";
8
- import "../utils/branch-protection.mjs";
9
- import { join, relative } from "node:path";
8
+ import { join } from "node:path";
10
9
  import { fromMarkdown } from "mdast-util-from-markdown";
11
10
  import { gfmFromMarkdown } from "mdast-util-gfm";
12
11
  import { gfm } from "micromark-extension-gfm";
@@ -108,7 +107,7 @@ const generate_release_pr = create_command({
108
107
  await platform.create_or_update_pull_request({
109
108
  head_branch_name: release_branch_name,
110
109
  base_branch_name: config.git.target_branch,
111
- title: `chore: prepare release ${app.name}@${next_version}`,
110
+ title: `release: ${app.name}@${next_version}`,
112
111
  body: formatter.generate_pr_body({
113
112
  app: { name: app.name },
114
113
  current_version,
@@ -3,7 +3,6 @@ import { create_logger } from "../utils/logger.mjs";
3
3
  import { find_nearest_config } from "../config.mjs";
4
4
  import { get_head_and_parent_shas, read_file_at_revision } from "../utils/git.mjs";
5
5
  import { compute_current_version } from "../utils/version.mjs";
6
- import "../utils/branch-protection.mjs";
7
6
  import { relative } from "node:path";
8
7
 
9
8
  //#region src/lib/commands/tag-release-commit.ts
@@ -111,6 +111,7 @@ function default_formatter({ allowed_changes, display_map }) {
111
111
  release_lines.push(`### ${heading}`, "");
112
112
  for (const change of kind_changes) release_lines.push(`- ${change.summary.split("\n").join("\n ")}`, "");
113
113
  }
114
+ if (release.changes.length === 0) release_lines.push("No changes in this release.");
114
115
  lines.push(release_lines.join("\n"));
115
116
  }
116
117
  return lines.join("\n\n");
@@ -75,24 +75,27 @@ function github(options) {
75
75
  parents: [base_sha]
76
76
  })
77
77
  });
78
+ let branch_exists = false;
78
79
  try {
79
- await api_request(`/git/refs/heads/${branch_name}`, {
80
- method: "PATCH",
81
- body: JSON.stringify({
82
- sha: commit.sha,
83
- force: false
84
- })
85
- });
80
+ await api_request(`/git/ref/heads/${branch_name}`);
81
+ branch_exists = true;
86
82
  } catch (error) {
87
- if (error.message.includes("404")) await api_request("/git/refs", {
88
- method: "POST",
89
- body: JSON.stringify({
90
- ref: `refs/heads/${branch_name}`,
91
- sha: commit.sha
92
- })
93
- });
94
- else throw error;
83
+ if (!error.message.includes("404")) throw error;
95
84
  }
85
+ if (branch_exists) await api_request(`/git/refs/heads/${branch_name}`, {
86
+ method: "PATCH",
87
+ body: JSON.stringify({
88
+ sha: commit.sha,
89
+ force: true
90
+ })
91
+ });
92
+ else await api_request("/git/refs", {
93
+ method: "POST",
94
+ body: JSON.stringify({
95
+ ref: `refs/heads/${branch_name}`,
96
+ sha: commit.sha
97
+ })
98
+ });
96
99
  return commit.sha;
97
100
  },
98
101
  async create_or_update_pull_request(args) {
@@ -65,8 +65,8 @@ ${error_text}`);
65
65
  branch: branch_name,
66
66
  commit_message,
67
67
  actions,
68
- start_branch: branch_exists ? branch_name : void 0,
69
- start_sha: branch_exists ? void 0 : base_sha
68
+ start_sha: base_sha,
69
+ force: branch_exists
70
70
  })
71
71
  })).id;
72
72
  },
@@ -80,7 +80,7 @@ ${error_text}`);
80
80
  body: JSON.stringify({
81
81
  title,
82
82
  description: body,
83
- work_in_progress: draft
83
+ draft
84
84
  })
85
85
  });
86
86
  return {
@@ -97,7 +97,7 @@ ${error_text}`);
97
97
  target_branch: base_branch_name,
98
98
  title,
99
99
  description: body,
100
- work_in_progress: draft
100
+ draft
101
101
  })
102
102
  });
103
103
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afoures/auto-release",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "A file based release management tool for monorepos",
5
5
  "homepage": "https://github.com/afoures/auto-release#readme",
6
6
  "bugs": {