Skip to content

Commit fd60e5d

Browse files
committed
Merge branch '0.0.x'
2 parents 2caa749 + 6c7f287 commit fd60e5d

9 files changed

Lines changed: 89 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ jobs:
5454
with:
5555
version: ${{ needs.planner.outputs.release-version }}
5656
token: ${{ github.token }}
57-
website-token: ${{ github.token }}
58-
website-repository: 'spring-io/spring-release-actions'
57+
projects-api-base: '.'
5958
- name: "Ensure ${{ steps.next-release-milestone.outputs.version }} Scheduled"
6059
uses: ./schedule-milestone
6160
if: ${{ steps.next-release-milestone.outputs.version-type == 'oss' }}

compute-next-version/README.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ This GitHub action computes the next milestone release name and date.
2222
| `project-slug`
2323
| The project slug for the Projects API (https://api.spring.io/projects). Defaults to the repository name with `-commercial` stripped.
2424
| `false`
25+
26+
| `projects-api-base`
27+
| The base URL or filesystem path for the Projects API. Defaults to `https://api.spring.io`. Use `.` to read generation metadata from the local `projects/` directory.
28+
| `false`
2529
|===
2630

2731
== Outputs

compute-next-version/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ inputs:
1515
project-slug:
1616
description: "The project slug for the Projects API (https://api.spring.io/projects)"
1717
required: false
18+
projects-api-base:
19+
description: "The base URL or filesystem path for the Projects API. Defaults to 'https://api.spring.io'. Use '.' to read generation metadata from the local 'projects/' directory."
20+
required: false
1821

1922
outputs:
2023
version:

dist/compute-next-version/main/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35629,9 +35629,13 @@ function _isToday(dueDate) {
3562935629

3563035630

3563135631

35632+
;// CONCATENATED MODULE: external "fs/promises"
35633+
const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs/promises");
3563235634
;// CONCATENATED MODULE: ./src/website.js
3563335635

3563435636

35637+
35638+
3563535639
const PROJECTS_API_BASE = "https://api.spring.io";
3563635640

3563735641
/**
@@ -35686,6 +35690,13 @@ class Website {
3568635690
}
3568735691

3568835692
async function _fetchGenerations(apiBase, projectSlug) {
35693+
if (apiBase.startsWith("http://") || apiBase.startsWith("https://")) {
35694+
return _fetchGenerationsFromHttp(apiBase, projectSlug);
35695+
}
35696+
return _fetchGenerationsFromFilesystem(apiBase, projectSlug);
35697+
}
35698+
35699+
async function _fetchGenerationsFromHttp(apiBase, projectSlug) {
3568935700
const url = `${apiBase}/projects/${projectSlug}/generations`;
3569035701
try {
3569135702
console.log(`Retrieving generations from ${url}`);
@@ -35709,6 +35720,14 @@ async function _fetchGenerations(apiBase, projectSlug) {
3570935720
}
3571035721
}
3571135722

35723+
async function _fetchGenerationsFromFilesystem(apiBase, projectSlug) {
35724+
const filePath = (0,external_path_namespaceObject.join)(apiBase, "projects", projectSlug, "generations.json");
35725+
console.log(`Reading generations from ${filePath}`);
35726+
const content = await (0,promises_namespaceObject.readFile)(filePath, "utf-8");
35727+
const { generations } = JSON.parse(content);
35728+
return generations;
35729+
}
35730+
3571235731
function _generation(generation) {
3571335732
const parts = generation.split(/[.-]/);
3571435733
return { major: parseInt(parts[0]), minor: parseInt(parts[1]) };

dist/compute-next-version/main/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration-tests/compute-next-version.integration.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { mkdir, rm, writeFile } from "fs/promises";
2+
import { join } from "path";
3+
import { tmpdir } from "os";
14
import { vi } from "vitest";
25
import { http, HttpResponse } from "msw";
36
import { setupServer } from "msw/node";
@@ -48,4 +51,35 @@ describe("compute-next-version integration", () => {
4851
expect(core.setOutput).toHaveBeenCalledWith("version-type", expect.any(String));
4952
expect(core.setFailed).not.toHaveBeenCalled();
5053
});
54+
55+
it("reads generations from the filesystem when projectsApiBase is a path", async () => {
56+
const dir = await mkdir(join(tmpdir(), "spring-test"), { recursive: true });
57+
const apiBase = join(tmpdir(), "spring-test");
58+
await mkdir(join(apiBase, "projects", "spring-boot"), { recursive: true });
59+
await writeFile(
60+
join(apiBase, "projects", "spring-boot", "generations.json"),
61+
JSON.stringify({
62+
generations: [
63+
{ name: "1.0", ossSupportEndDate: "2028-01", commercialSupportEndDate: "2031-01" },
64+
],
65+
}),
66+
);
67+
68+
try {
69+
await run({
70+
version: "1.0.0",
71+
token: "test-token",
72+
repository: "owner/repo",
73+
projectSlug: "spring-boot",
74+
projectsApiBase: apiBase,
75+
});
76+
77+
expect(core.setOutput).toHaveBeenCalledWith("version", expect.any(String));
78+
expect(core.setOutput).toHaveBeenCalledWith("version-date", expect.any(String));
79+
expect(core.setOutput).toHaveBeenCalledWith("version-type", expect.any(String));
80+
expect(core.setFailed).not.toHaveBeenCalled();
81+
} finally {
82+
await rm(apiBase, { recursive: true });
83+
}
84+
});
5185
});

project/spring-release-actions/generations.json

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"generations": [
3+
{
4+
"name": "0.0.x",
5+
"initialRelease": "2026-01",
6+
"ossSupportEndDate": "2099-01",
7+
"commercialSupportEndDate": "2099-01"
8+
}
9+
]
10+
}

src/website.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { readFile } from "fs/promises";
2+
import { join } from "path";
13
import { getWeekOfMonthAndDayOfWeek } from "./lib.js";
24

35
const PROJECTS_API_BASE = "https://api.spring.io";
@@ -54,6 +56,13 @@ class Website {
5456
}
5557

5658
async function _fetchGenerations(apiBase, projectSlug) {
59+
if (apiBase.startsWith("http://") || apiBase.startsWith("https://")) {
60+
return _fetchGenerationsFromHttp(apiBase, projectSlug);
61+
}
62+
return _fetchGenerationsFromFilesystem(apiBase, projectSlug);
63+
}
64+
65+
async function _fetchGenerationsFromHttp(apiBase, projectSlug) {
5766
const url = `${apiBase}/projects/${projectSlug}/generations`;
5867
try {
5968
console.log(`Retrieving generations from ${url}`);
@@ -77,6 +86,14 @@ async function _fetchGenerations(apiBase, projectSlug) {
7786
}
7887
}
7988

89+
async function _fetchGenerationsFromFilesystem(apiBase, projectSlug) {
90+
const filePath = join(apiBase, "projects", projectSlug, "generations.json");
91+
console.log(`Reading generations from ${filePath}`);
92+
const content = await readFile(filePath, "utf-8");
93+
const { generations } = JSON.parse(content);
94+
return generations;
95+
}
96+
8097
function _generation(generation) {
8198
const parts = generation.split(/[.-]/);
8299
return { major: parseInt(parts[0]), minor: parseInt(parts[1]) };

0 commit comments

Comments
 (0)