Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f488cf82a | ||
|
|
372a8049d7 | ||
|
|
356b5a68f4 | ||
|
|
6d95698f76 | ||
|
|
c7293b6abd | ||
|
|
a13b7392fb | ||
|
|
7de2d094ec | ||
|
|
d7feb9d031 | ||
|
|
63e0340562 | ||
|
|
8ea6c1f538 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -32,6 +32,8 @@ jobs:
|
||||
run: npm run lint
|
||||
- name: Test
|
||||
run: npm run test
|
||||
env:
|
||||
INPUT_GITHUB_TOKEN: ${{ github.token }} # for core.getInput()
|
||||
|
||||
test-action:
|
||||
name: GraalVM
|
||||
|
||||
15
README.md
15
README.md
@@ -1,5 +1,7 @@
|
||||
# GitHub Action for GraalVM [](https://github.com/graalvm/setup-graalvm/actions/workflows/ci.yml)
|
||||
This GitHub action sets up [Oracle GraalVM][graalvm-medium], GraalVM [Community Edition (CE)][repo], [Enterprise Edition (EE)][graalvm-ee], [Mandrel][mandrel], or [Liberica Native Image Kit][liberica] as well as [Native Image][native-image] and GraalVM components such as [Truffle languages][truffle-languages].
|
||||
|
||||
Set up your GitHub Actions workflow with a specific [GraalVM][graalvm] distribution, and use it both as your JDK and for [ahead-of-time Native Image compilation][graalvm].
|
||||
|
||||
|
||||
## Key Features
|
||||
|
||||
@@ -7,12 +9,10 @@ This action:
|
||||
|
||||
- supports Oracle GraalVM [releases][graalvm-dl], [EA builds][ea-builds], GraalVM Community Edition (CE) [releases], [dev builds][dev-builds], GraalVM Enterprise Edition (EE) [releases][graalvm-ee] (set [`gds-token`](#options)) 22.1.0 and later, [Mandrel][mandrel], and [Liberica Native Image Kit][liberica] (see [Options](#options))
|
||||
- exports a `$GRAALVM_HOME` environment variable
|
||||
- adds `$GRAALVM_HOME/bin` to the `$PATH` environment variable<br>(Native Image, Truffle languages, and tools can be invoked directly)
|
||||
- adds `$GRAALVM_HOME/bin` to the `$PATH` environment variable<br>(`native-image`, `javac`, and other JDK tools can be invoked directly)
|
||||
- sets `$JAVA_HOME` to `$GRAALVM_HOME` by default<br>(can be disabled via `set-java-home: 'false'`, see [Options](#options))
|
||||
- supports `x64` and `aarch64/arm64` (see how to use [Linux arm64 runners](https://github.blog/changelog/2025-01-16-linux-arm64-hosted-runners-now-available-for-free-in-public-repositories-public-preview/))
|
||||
- supports dependency caching for Apache Maven, Gradle, and sbt (see [`cache` option](#options))
|
||||
- sets up Windows environments with build tools using [vcvarsall.bat][vcvarsall]
|
||||
- has built-in support for GraalVM components and the [GraalVM Updater][gu]
|
||||
|
||||
|
||||
## Templates
|
||||
@@ -270,21 +270,16 @@ Only pull requests from committers that can be verified as having signed the OCA
|
||||
[gha-self-hosted-runners]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
|
||||
[gu]: https://www.graalvm.org/reference-manual/graalvm-updater/
|
||||
[graalvm]: https://www.graalvm.org/
|
||||
[graalvm-dl]: https://www.oracle.com/java/technologies/downloads/
|
||||
[graalvm-medium]: https://medium.com/graalvm/a-new-graalvm-release-and-new-free-license-4aab483692f5
|
||||
[graalvm-dl]: https://www.graalvm.org/downloads/
|
||||
[graalvm-ee]: https://www.oracle.com/downloads/graalvm-downloads.html
|
||||
[liberica]: https://bell-sw.com/liberica-native-image-kit/
|
||||
[mandrel]: https://github.com/graalvm/mandrel
|
||||
[mandrel-releases]: https://github.com/graalvm/mandrel/releases
|
||||
[mandrel-stable]: https://github.com/graalvm/mandrel/releases/latest
|
||||
[musl]: https://musl.libc.org/
|
||||
[native-image]: https://www.graalvm.org/native-image/
|
||||
[native-image-musl-build]: https://github.com/graalvm/setup-graalvm/blob/778131f1d6837ccd4b2e91382c31830896a2d56e/.github/workflows/test.yml#L74-L92
|
||||
[native-image-static]: https://github.com/oracle/graal/blob/fa6f4a974dedacf4688dcc430dd100849d9882f2/docs/reference-manual/native-image/StaticImages.md
|
||||
[oca]: https://oca.opensource.oracle.com
|
||||
[releases]: https://github.com/graalvm/graalvm-ce-builds/releases
|
||||
[repo]: https://github.com/oracle/graal
|
||||
[setup-java-caching]: https://github.com/actions/setup-java/tree/5b36705a13905facb447b6812d613a06a07e371d#caching-packages-dependencies
|
||||
[stable]: https://github.com/graalvm/graalvm-ce-builds/releases/latest
|
||||
[truffle-languages]: https://www.graalvm.org/reference-manual/languages/
|
||||
[vcvarsall]: https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line
|
||||
|
||||
47
dist/cleanup/index.js
generated
vendored
47
dist/cleanup/index.js
generated
vendored
@@ -78281,7 +78281,7 @@ run();
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_LIBERICA = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.NATIVE_IMAGE_OPTIONS_ENV = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = exports.ACTION_VERSION = void 0;
|
||||
exports.ACTION_VERSION = '1.3.3';
|
||||
exports.ACTION_VERSION = '1.3.5';
|
||||
exports.INPUT_VERSION = 'version';
|
||||
exports.INPUT_GDS_TOKEN = 'gds-token';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
@@ -79190,24 +79190,15 @@ exports.setNativeImageOption = setNativeImageOption;
|
||||
const c = __importStar(__nccwpck_require__(7242));
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const github = __importStar(__nccwpck_require__(3228));
|
||||
const httpClient = __importStar(__nccwpck_require__(4844));
|
||||
const semver = __importStar(__nccwpck_require__(2088));
|
||||
const tc = __importStar(__nccwpck_require__(3472));
|
||||
const fs = __importStar(__nccwpck_require__(9896));
|
||||
const exec_1 = __nccwpck_require__(5236);
|
||||
const fs_1 = __nccwpck_require__(9896);
|
||||
const core_1 = __nccwpck_require__(1897);
|
||||
const crypto_1 = __nccwpck_require__(6982);
|
||||
const path_1 = __nccwpck_require__(6928);
|
||||
const os_1 = __nccwpck_require__(857);
|
||||
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
||||
const baseUrl = 'https://api.github.com';
|
||||
const GitHubDotCom = core_1.Octokit.defaults({
|
||||
baseUrl,
|
||||
request: {
|
||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
||||
}
|
||||
});
|
||||
const utils_1 = __nccwpck_require__(8006);
|
||||
async function exec(commandLine, args, options) {
|
||||
const exitCode = await (0, exec_1.exec)(commandLine, args, options);
|
||||
if (exitCode !== 0) {
|
||||
@@ -79215,18 +79206,14 @@ async function exec(commandLine, args, options) {
|
||||
}
|
||||
}
|
||||
async function getLatestRelease(repo) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo
|
||||
})).data;
|
||||
}
|
||||
async function getContents(repo, path) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
@@ -79234,9 +79221,7 @@ async function getContents(repo, path) {
|
||||
})).data;
|
||||
}
|
||||
async function getTaggedRelease(owner, repo, tag) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||
owner,
|
||||
repo,
|
||||
@@ -79244,9 +79229,7 @@ async function getTaggedRelease(owner, repo, tag) {
|
||||
})).data;
|
||||
}
|
||||
async function getMatchingTags(owner, repo, tagPrefix) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||
owner,
|
||||
repo,
|
||||
@@ -79314,15 +79297,23 @@ function toSemVer(version) {
|
||||
function isPREvent() {
|
||||
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST;
|
||||
}
|
||||
function getGitHubToken() {
|
||||
return core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||
function getOctokit() {
|
||||
/* Set up GitHub instance manually because @actions/github does not allow unauthenticated access */
|
||||
const GitHubWithPlugins = utils_1.GitHub.plugin();
|
||||
const token = core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||
if (token) {
|
||||
return new GitHubWithPlugins({ auth: `token ${token}` });
|
||||
}
|
||||
else {
|
||||
return new GitHubWithPlugins(); /* unauthenticated */
|
||||
}
|
||||
}
|
||||
async function findExistingPRCommentId(bodyStartsWith) {
|
||||
if (!isPREvent()) {
|
||||
throw new Error('Not a PR event.');
|
||||
}
|
||||
const context = github.context;
|
||||
const octokit = github.getOctokit(getGitHubToken());
|
||||
const octokit = getOctokit();
|
||||
try {
|
||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||
...context.repo,
|
||||
@@ -79342,7 +79333,7 @@ async function updatePRComment(content, commentId) {
|
||||
throw new Error('Not a PR event.');
|
||||
}
|
||||
try {
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.updateComment({
|
||||
await getOctokit().rest.issues.updateComment({
|
||||
...github.context.repo,
|
||||
comment_id: commentId,
|
||||
body: content
|
||||
@@ -79358,7 +79349,7 @@ async function createPRComment(content) {
|
||||
}
|
||||
const context = github.context;
|
||||
try {
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
||||
await getOctokit().rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.payload.pull_request?.number,
|
||||
body: content
|
||||
|
||||
47
dist/main/index.js
generated
vendored
47
dist/main/index.js
generated
vendored
@@ -78177,7 +78177,7 @@ function wrappy (fn, cb) {
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_LIBERICA = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.NATIVE_IMAGE_OPTIONS_ENV = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = exports.ACTION_VERSION = void 0;
|
||||
exports.ACTION_VERSION = '1.3.3';
|
||||
exports.ACTION_VERSION = '1.3.5';
|
||||
exports.INPUT_VERSION = 'version';
|
||||
exports.INPUT_GDS_TOKEN = 'gds-token';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
@@ -80484,24 +80484,15 @@ exports.setNativeImageOption = setNativeImageOption;
|
||||
const c = __importStar(__nccwpck_require__(7242));
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const github = __importStar(__nccwpck_require__(3228));
|
||||
const httpClient = __importStar(__nccwpck_require__(4844));
|
||||
const semver = __importStar(__nccwpck_require__(2088));
|
||||
const tc = __importStar(__nccwpck_require__(3472));
|
||||
const fs = __importStar(__nccwpck_require__(9896));
|
||||
const exec_1 = __nccwpck_require__(5236);
|
||||
const fs_1 = __nccwpck_require__(9896);
|
||||
const core_1 = __nccwpck_require__(1897);
|
||||
const crypto_1 = __nccwpck_require__(6982);
|
||||
const path_1 = __nccwpck_require__(6928);
|
||||
const os_1 = __nccwpck_require__(857);
|
||||
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
||||
const baseUrl = 'https://api.github.com';
|
||||
const GitHubDotCom = core_1.Octokit.defaults({
|
||||
baseUrl,
|
||||
request: {
|
||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
||||
}
|
||||
});
|
||||
const utils_1 = __nccwpck_require__(8006);
|
||||
async function exec(commandLine, args, options) {
|
||||
const exitCode = await (0, exec_1.exec)(commandLine, args, options);
|
||||
if (exitCode !== 0) {
|
||||
@@ -80509,18 +80500,14 @@ async function exec(commandLine, args, options) {
|
||||
}
|
||||
}
|
||||
async function getLatestRelease(repo) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo
|
||||
})).data;
|
||||
}
|
||||
async function getContents(repo, path) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
@@ -80528,9 +80515,7 @@ async function getContents(repo, path) {
|
||||
})).data;
|
||||
}
|
||||
async function getTaggedRelease(owner, repo, tag) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||
owner,
|
||||
repo,
|
||||
@@ -80538,9 +80523,7 @@ async function getTaggedRelease(owner, repo, tag) {
|
||||
})).data;
|
||||
}
|
||||
async function getMatchingTags(owner, repo, tagPrefix) {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
const octokit = getOctokit();
|
||||
return (await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||
owner,
|
||||
repo,
|
||||
@@ -80608,15 +80591,23 @@ function toSemVer(version) {
|
||||
function isPREvent() {
|
||||
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST;
|
||||
}
|
||||
function getGitHubToken() {
|
||||
return core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||
function getOctokit() {
|
||||
/* Set up GitHub instance manually because @actions/github does not allow unauthenticated access */
|
||||
const GitHubWithPlugins = utils_1.GitHub.plugin();
|
||||
const token = core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||
if (token) {
|
||||
return new GitHubWithPlugins({ auth: `token ${token}` });
|
||||
}
|
||||
else {
|
||||
return new GitHubWithPlugins(); /* unauthenticated */
|
||||
}
|
||||
}
|
||||
async function findExistingPRCommentId(bodyStartsWith) {
|
||||
if (!isPREvent()) {
|
||||
throw new Error('Not a PR event.');
|
||||
}
|
||||
const context = github.context;
|
||||
const octokit = github.getOctokit(getGitHubToken());
|
||||
const octokit = getOctokit();
|
||||
try {
|
||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||
...context.repo,
|
||||
@@ -80636,7 +80627,7 @@ async function updatePRComment(content, commentId) {
|
||||
throw new Error('Not a PR event.');
|
||||
}
|
||||
try {
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.updateComment({
|
||||
await getOctokit().rest.issues.updateComment({
|
||||
...github.context.repo,
|
||||
comment_id: commentId,
|
||||
body: content
|
||||
@@ -80652,7 +80643,7 @@ async function createPRComment(content) {
|
||||
}
|
||||
const context = github.context;
|
||||
try {
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
||||
await getOctokit().rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.payload.pull_request?.number,
|
||||
body: content
|
||||
|
||||
733
package-lock.json
generated
733
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@@ -2,7 +2,7 @@
|
||||
"name": "setup-graalvm",
|
||||
"author": "GraalVM Community",
|
||||
"description": "GitHub Action for GraalVM",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.5",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -41,34 +41,33 @@
|
||||
"@actions/http-client": "^2.2.3",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"@octokit/core": "^5.2.0",
|
||||
"@octokit/types": "^14.1.0",
|
||||
"@github/dependency-submission-toolkit": "^2.0.5",
|
||||
"semver": "^7.7.2",
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.9",
|
||||
"@eslint/compat": "^1.3.1",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.17.57",
|
||||
"@types/node": "^20.19.4",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.33.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
||||
"@typescript-eslint/parser": "^8.31.1",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint": "^9.30.1",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-import-resolver-typescript": "^4.4.2",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.12.0",
|
||||
"eslint-import-resolver-typescript": "^4.4.4",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-jsonc": "^2.20.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^5.4.1",
|
||||
"eslint-plugin-prettier": "^5.5.1",
|
||||
"jest": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-eslint": "^16.4.2",
|
||||
"ts-jest": "^29.3.4",
|
||||
"ts-jest": "^29.4.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as otypes from '@octokit/types'
|
||||
|
||||
export const ACTION_VERSION = '1.3.3'
|
||||
export const ACTION_VERSION = '1.3.5'
|
||||
|
||||
export const INPUT_VERSION = 'version'
|
||||
export const INPUT_GDS_TOKEN = 'gds-token'
|
||||
|
||||
45
src/utils.ts
45
src/utils.ts
@@ -1,25 +1,15 @@
|
||||
import * as c from './constants'
|
||||
import * as core from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import * as httpClient from '@actions/http-client'
|
||||
import * as semver from 'semver'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import * as fs from 'fs'
|
||||
import { ExecOptions, exec as e } from '@actions/exec'
|
||||
import { readFileSync, readdirSync } from 'fs'
|
||||
import { Octokit } from '@octokit/core'
|
||||
import { createHash } from 'crypto'
|
||||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
|
||||
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
||||
const baseUrl = 'https://api.github.com'
|
||||
const GitHubDotCom = Octokit.defaults({
|
||||
baseUrl,
|
||||
request: {
|
||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
||||
}
|
||||
})
|
||||
import { GitHub } from '@actions/github/lib/utils'
|
||||
|
||||
export async function exec(commandLine: string, args?: string[], options?: ExecOptions | undefined): Promise<void> {
|
||||
const exitCode = await e(commandLine, args, options)
|
||||
@@ -29,9 +19,7 @@ export async function exec(commandLine: string, args?: string[], options?: ExecO
|
||||
}
|
||||
|
||||
export async function getLatestRelease(repo: string): Promise<c.LatestReleaseResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
const octokit = getOctokit()
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
@@ -41,9 +29,7 @@ export async function getLatestRelease(repo: string): Promise<c.LatestReleaseRes
|
||||
}
|
||||
|
||||
export async function getContents(repo: string, path: string): Promise<c.ContentsResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
const octokit = getOctokit()
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
@@ -58,9 +44,7 @@ export async function getTaggedRelease(
|
||||
repo: string,
|
||||
tag: string
|
||||
): Promise<c.LatestReleaseResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
const octokit = getOctokit()
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||
owner,
|
||||
@@ -75,9 +59,7 @@ export async function getMatchingTags(
|
||||
repo: string,
|
||||
tagPrefix: string
|
||||
): Promise<c.MatchingRefsResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
const octokit = getOctokit()
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||
owner,
|
||||
@@ -156,8 +138,15 @@ export function isPREvent(): boolean {
|
||||
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST
|
||||
}
|
||||
|
||||
function getGitHubToken(): string {
|
||||
return core.getInput(c.INPUT_GITHUB_TOKEN)
|
||||
function getOctokit(): InstanceType<typeof GitHub> {
|
||||
/* Set up GitHub instance manually because @actions/github does not allow unauthenticated access */
|
||||
const GitHubWithPlugins = GitHub.plugin()
|
||||
const token = core.getInput(c.INPUT_GITHUB_TOKEN)
|
||||
if (token) {
|
||||
return new GitHubWithPlugins({ auth: `token ${token}` })
|
||||
} else {
|
||||
return new GitHubWithPlugins() /* unauthenticated */
|
||||
}
|
||||
}
|
||||
|
||||
export async function findExistingPRCommentId(bodyStartsWith: string): Promise<number | undefined> {
|
||||
@@ -166,7 +155,7 @@ export async function findExistingPRCommentId(bodyStartsWith: string): Promise<n
|
||||
}
|
||||
|
||||
const context = github.context
|
||||
const octokit = github.getOctokit(getGitHubToken())
|
||||
const octokit = getOctokit()
|
||||
try {
|
||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||
...context.repo,
|
||||
@@ -189,7 +178,7 @@ export async function updatePRComment(content: string, commentId: number): Promi
|
||||
}
|
||||
|
||||
try {
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.updateComment({
|
||||
await getOctokit().rest.issues.updateComment({
|
||||
...github.context.repo,
|
||||
comment_id: commentId,
|
||||
body: content
|
||||
@@ -207,7 +196,7 @@ export async function createPRComment(content: string): Promise<void> {
|
||||
}
|
||||
const context = github.context
|
||||
try {
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
||||
await getOctokit().rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.payload.pull_request?.number as number,
|
||||
body: content
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"isolatedModules": true,
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./dist"
|
||||
|
||||
Reference in New Issue
Block a user