repokeeper 0.4.2 → 0.4.4

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.
package/README.md CHANGED
@@ -78,7 +78,11 @@ work:
78
78
  pull requests.
79
79
  - Optionally add a `RELEASE_PLEASE_TOKEN` secret (a fine-grained token with contents, pull requests
80
80
  and issues write access). Without it the release pull request is opened with `GITHUB_TOKEN`, and
81
- GitHub does not run CI on pull requests opened that way.
81
+ GitHub holds its `pull_request` runs until someone approves them; the `release-pr-ci` job approves
82
+ them, so the pull request gets its checks and required checks in a ruleset can pass.
83
+
84
+ A repository with no release yet (manifest at `0.0.0`) gets `initial-version: 0.1.0`, so its first
85
+ release is 0.1.0 rather than release-please's default 1.0.0.
82
86
 
83
87
  Set `modules.drift: true` to add a `repokeeper` job to `ci.yml` that runs `repokeeper check` with
84
88
  the version that wrote the standard, so a pull request that edits a managed file fails until the edit
@@ -22,6 +22,15 @@ const workflowKey = (module, path, keyPath, value) => ({
22
22
  value,
23
23
  order: WORKFLOW_KEYS,
24
24
  });
25
+ /** Waits briefly for the held runs to appear, since GitHub creates them just after the pull request event. */
26
+ const APPROVE_RELEASE_PR_RUNS = `for attempt in 1 2 3 4 5 6; do
27
+ ids=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs?branch=$BRANCH&event=pull_request&status=action_required" --jq '.workflow_runs[].id')
28
+ [ -n "$ids" ] && break
29
+ sleep 10
30
+ done
31
+ if [ -z "$ids" ]; then echo "::notice::no held runs for $BRANCH"; fi
32
+ for id in $ids; do gh api -X POST "repos/$GITHUB_REPOSITORY/actions/runs/$id/approve"; done
33
+ `;
25
34
  const RELEASE_PLEASE_SCHEMA = "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json";
26
35
  const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
27
36
  export const githubPlatform = {
@@ -146,6 +155,7 @@ export const githubPlatform = {
146
155
  },
147
156
  releaseAutomation(ctx, release) {
148
157
  const path = ".github/workflows/release.yml";
158
+ const seed = release.version ?? ctx.repo.releasedVersion ?? "0.0.0";
149
159
  return [
150
160
  {
151
161
  kind: "file",
@@ -161,6 +171,10 @@ export const githubPlatform = {
161
171
  "include-component-in-tag": false,
162
172
  ...(release.extraFiles && release.extraFiles.length > 0 ? { "extra-files": release.extraFiles } : {}),
163
173
  ...(release.versionFile ? { "version-file": release.versionFile } : {}),
174
+ // Without it a pom at a release version first gets a pull request that only bumps to -SNAPSHOT
175
+ ...(release.type === "maven" ? { "skip-snapshot": true } : {}),
176
+ // release-please makes a repository's first release 1.0.0 unless told otherwise
177
+ ...(seed === "0.0.0" ? { "initial-version": "0.1.0" } : {}),
164
178
  },
165
179
  },
166
180
  }),
@@ -169,7 +183,7 @@ export const githubPlatform = {
169
183
  kind: "seed",
170
184
  module: "release",
171
185
  path: ".release-please-manifest.json",
172
- content: json({ ".": release.version ?? ctx.repo.releasedVersion ?? "0.0.0" }),
186
+ content: json({ ".": seed }),
173
187
  },
174
188
  workflowKey("release", path, ["name"], "release"),
175
189
  workflowKey("release", path, ["on"], { push: { branches: [defaultBranch(ctx.config)] } }),
@@ -180,6 +194,26 @@ export const githubPlatform = {
180
194
  // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, not a JS template
181
195
  secrets: { token: "${{ secrets.RELEASE_PLEASE_TOKEN }}" },
182
196
  }),
197
+ // GitHub holds the pull_request runs of a pull request that GITHUB_TOKEN opened until someone
198
+ // approves them, so required checks never report; approve them for the release pull request
199
+ workflowKey("release", path, ["jobs", "release-pr-ci"], {
200
+ needs: "release",
201
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, not a JS template
202
+ if: "${{ needs.release.outputs.pr_branch != '' }}",
203
+ "runs-on": "ubuntu-latest",
204
+ permissions: { actions: "write" },
205
+ steps: [
206
+ {
207
+ env: {
208
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, not a JS template
209
+ GH_TOKEN: "${{ github.token }}",
210
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub Actions expression, not a JS template
211
+ BRANCH: "${{ needs.release.outputs.pr_branch }}",
212
+ },
213
+ run: APPROVE_RELEASE_PR_RUNS,
214
+ },
215
+ ],
216
+ }),
183
217
  ];
184
218
  },
185
219
  };
package/dist/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  export const PACKAGE_VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
3
3
  /** The standard this build of repokeeper applies. Bump it whenever generated output changes. */
4
- export const STANDARD_VERSION = "1.3.1";
4
+ export const STANDARD_VERSION = "1.4.0";
5
5
  export const TOOL_VERSIONS = {
6
6
  lefthook: "2.1.14",
7
7
  commitlintCli: "21.2.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repokeeper",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Keep every repository on one maintained standard: commits, git hooks, CI, releases, dependency updates and repo settings.",
5
5
  "type": "module",
6
6
  "bin": {