Skip to content

Commit 7b00cfc

Browse files
committed
Removed extra alpine logic
1 parent a034e00 commit 7b00cfc

4 files changed

Lines changed: 2 additions & 179 deletions

File tree

‎__tests__/data/microsoft.json‎

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -122,55 +122,6 @@
122122
}
123123
]
124124
},
125-
{
126-
"version": "17.0.9",
127-
"stable": true,
128-
"release_url": "https://aka.ms/download-jdk",
129-
"files": [
130-
{
131-
"filename": "microsoft-jdk-17.0.9-macos-x64.tar.gz",
132-
"arch": "x64",
133-
"platform": "darwin",
134-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-macos-x64.tar.gz"
135-
},
136-
{
137-
"filename": "microsoft-jdk-17.0.9-linux-x64.tar.gz",
138-
"arch": "x64",
139-
"platform": "linux",
140-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-linux-x64.tar.gz"
141-
},
142-
{
143-
"filename": "microsoft-jdk-17.0.9-windows-x64.zip",
144-
"arch": "x64",
145-
"platform": "win32",
146-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-windows-x64.zip"
147-
},
148-
{
149-
"filename": "microsoft-jdk-17.0.9-alpine-x64.tar.gz",
150-
"arch": "x64",
151-
"platform": "alpine",
152-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-alpine-x64.tar.gz"
153-
},
154-
{
155-
"filename": "microsoft-jdk-17.0.9-macos-aarch64.tar.gz",
156-
"arch": "aarch64",
157-
"platform": "darwin",
158-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-macos-aarch64.tar.gz"
159-
},
160-
{
161-
"filename": "microsoft-jdk-17.0.9-linux-aarch64.tar.gz",
162-
"arch": "aarch64",
163-
"platform": "linux",
164-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-linux-aarch64.tar.gz"
165-
},
166-
{
167-
"filename": "microsoft-jdk-17.0.9-windows-aarch64.zip",
168-
"arch": "aarch64",
169-
"platform": "win32",
170-
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-windows-aarch64.zip"
171-
}
172-
]
173-
},
174125
{
175126
"version": "17.0.7",
176127
"stable": true,

‎__tests__/distributors/microsoft-installer.test.ts‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -196,35 +196,6 @@ describe('findPackageForDownload', () => {
196196
);
197197
});
198198

199-
it('prefers Alpine package when running on Alpine and requesting JDK 17', async () => {
200-
jest.spyOn(distribution as any, 'isRunningOnAlpine').mockReturnValue(true);
201-
202-
const result = await distribution['findPackageForDownload']('17.0.9');
203-
204-
expect(result.version).toBe('17.0.9');
205-
expect(result.url).toBe(
206-
'https://aka.ms/download-jdk/microsoft-jdk-17.0.9-alpine-x64.tar.gz'
207-
);
208-
expect(result.signatureUrl).toBe(
209-
'https://aka.ms/download-jdk/microsoft-jdk-17.0.9-alpine-x64.tar.gz.sig'
210-
);
211-
});
212-
213-
it('falls back to generic linux manifest matching for unsupported major streams on Alpine', async () => {
214-
jest.spyOn(distribution as any, 'isRunningOnAlpine').mockReturnValue(true);
215-
jest.spyOn(os, 'platform').mockReturnValue('linux');
216-
217-
const result = await distribution['findPackageForDownload']('21.x');
218-
219-
expect(result.version).toBe('21.0.0');
220-
expect(result.url).toBe(
221-
'https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz'
222-
);
223-
expect(result.signatureUrl).toBe(
224-
'https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz.sig'
225-
);
226-
});
227-
228199
it('uses manifest-provided signature URL when available', async () => {
229200
spyGetManifestFromRepo.mockReturnValue({
230201
result: [

‎dist/setup/index.js‎

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -79932,7 +79932,6 @@ const core = __importStar(__nccwpck_require__(37484));
7993279932
const tc = __importStar(__nccwpck_require__(33472));
7993379933
const fs_1 = __importDefault(__nccwpck_require__(79896));
7993479934
const path_1 = __importDefault(__nccwpck_require__(16928));
79935-
const semver_1 = __importDefault(__nccwpck_require__(62088));
7993679935
var microsoft_key_2 = __nccwpck_require__(56286);
7993779936
Object.defineProperty(exports, "MICROSOFT_PUBLIC_KEY", ({ enumerable: true, get: function () { return microsoft_key_2.MICROSOFT_PUBLIC_KEY; } }));
7993879937
class MicrosoftDistributions extends base_installer_1.JavaBase {
@@ -79985,21 +79984,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
7998579984
if (!manifest) {
7998679985
throw new Error('Could not load manifest for Microsoft Build of OpenJDK');
7998779986
}
79988-
let foundRelease;
79989-
if (this.isRunningOnAlpine() && this.isAlpineSupportedVersion(range)) {
79990-
foundRelease = this.findFromManifestForPlatform(range, manifest, arch, 'alpine');
79991-
if (foundRelease) {
79992-
core.debug(`Resolved Alpine package for Microsoft OpenJDK ${range}`);
79993-
}
79994-
}
79995-
else if (this.isRunningOnAlpine()) {
79996-
core.debug(`No Alpine package found for Microsoft OpenJDK ${range}, defaulting to standard linux package`);
79997-
}
79998-
// Runs if user is not running on alpine, or if no Alpine package was found
79999-
if (!foundRelease) {
80000-
foundRelease = yield tc.findFromManifest(range, true, manifest, arch);
80001-
}
80002-
// Runs if failed to find any matching package
79987+
const foundRelease = yield tc.findFromManifest(range, true, manifest, arch);
8000379988
if (!foundRelease) {
8000479989
const availableVersionStrings = manifest.map(item => item.version);
8000579990
throw this.createVersionNotFoundError(range, availableVersionStrings);
@@ -80013,28 +79998,6 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
8001379998
};
8001479999
});
8001580000
}
80016-
findFromManifestForPlatform(range, manifest, arch, platform) {
80017-
const matched = manifest
80018-
.filter(release => release.stable)
80019-
.filter(release => (0, util_1.isVersionSatisfies)(range, release.version))
80020-
.map(release => {
80021-
const matchedFile = release.files.find((file) => file.arch === arch && file.platform === platform);
80022-
if (!matchedFile) {
80023-
return null;
80024-
}
80025-
return Object.assign(Object.assign({}, release), { files: [matchedFile] });
80026-
})
80027-
.filter((release) => release !== null)
80028-
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version));
80029-
return matched[0];
80030-
}
80031-
isAlpineSupportedVersion(range) {
80032-
const minVersion = semver_1.default.minVersion(range);
80033-
return !!minVersion && (minVersion.major === 11 || minVersion.major === 17);
80034-
}
80035-
isRunningOnAlpine() {
80036-
return process.platform === 'linux' && fs_1.default.existsSync('/etc/alpine-release');
80037-
}
8003880001
supportsSignatureVerification() {
8003980002
return true;
8004080003
}

‎src/distributions/microsoft/installer.ts‎

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
extractJdkFile,
99
getDownloadArchiveExtension,
1010
getGitHubHttpHeaders,
11-
isVersionSatisfies,
1211
renameWinArchive
1312
} from '../../util';
1413
import * as gpg from '../../gpg';
@@ -17,7 +16,6 @@ import * as core from '@actions/core';
1716
import * as tc from '@actions/tool-cache';
1817
import fs from 'fs';
1918
import path from 'path';
20-
import semver from 'semver';
2119
import {TypedResponse} from '@actions/http-client/lib/interfaces';
2220

2321
export {MICROSOFT_PUBLIC_KEY} from './microsoft-key';
@@ -99,30 +97,8 @@ export class MicrosoftDistributions extends JavaBase {
9997
throw new Error('Could not load manifest for Microsoft Build of OpenJDK');
10098
}
10199

102-
let foundRelease: tc.IToolRelease | undefined;
100+
const foundRelease = await tc.findFromManifest(range, true, manifest, arch);
103101

104-
if (this.isRunningOnAlpine() && this.isAlpineSupportedVersion(range)) {
105-
foundRelease = this.findFromManifestForPlatform(
106-
range,
107-
manifest,
108-
arch,
109-
'alpine'
110-
);
111-
if (foundRelease) {
112-
core.debug(`Resolved Alpine package for Microsoft OpenJDK ${range}`);
113-
}
114-
} else if (this.isRunningOnAlpine()) {
115-
core.debug(
116-
`No Alpine package found for Microsoft OpenJDK ${range}, defaulting to standard linux package`
117-
);
118-
}
119-
120-
// Runs if user is not running on alpine, or if no Alpine package was found
121-
if (!foundRelease) {
122-
foundRelease = await tc.findFromManifest(range, true, manifest, arch);
123-
}
124-
125-
// Runs if failed to find any matching package
126102
if (!foundRelease) {
127103
const availableVersionStrings = manifest.map(item => item.version);
128104
throw this.createVersionNotFoundError(range, availableVersionStrings);
@@ -141,44 +117,6 @@ export class MicrosoftDistributions extends JavaBase {
141117
};
142118
}
143119

144-
private findFromManifestForPlatform(
145-
range: string,
146-
manifest: tc.IToolRelease[],
147-
arch: string,
148-
platform: string
149-
): tc.IToolRelease | undefined {
150-
const matched = manifest
151-
.filter(release => release.stable)
152-
.filter(release => isVersionSatisfies(range, release.version))
153-
.map(release => {
154-
const matchedFile = release.files.find(
155-
(file: tc.IToolReleaseFile) =>
156-
file.arch === arch && file.platform === platform
157-
);
158-
if (!matchedFile) {
159-
return null;
160-
}
161-
162-
return {
163-
...release,
164-
files: [matchedFile]
165-
};
166-
})
167-
.filter((release): release is tc.IToolRelease => release !== null)
168-
.sort((a, b) => -semver.compareBuild(a.version, b.version));
169-
170-
return matched[0];
171-
}
172-
173-
private isAlpineSupportedVersion(range: string): boolean {
174-
const minVersion = semver.minVersion(range);
175-
return !!minVersion && (minVersion.major === 11 || minVersion.major === 17);
176-
}
177-
178-
private isRunningOnAlpine(): boolean {
179-
return process.platform === 'linux' && fs.existsSync('/etc/alpine-release');
180-
}
181-
182120
protected supportsSignatureVerification(): boolean {
183121
return true;
184122
}

0 commit comments

Comments
 (0)