Skip to content

actions 2 #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# setup-protoc
# setup-protoc-to-env

[![Check npm Dependencies status](https://github.com/arduino/setup-protoc/actions/workflows/check-npm-dependencies-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-npm-dependencies-task.yml)
![test](https://github.com/arduino/setup-protoc/workflows/test/badge.svg)
Expand All @@ -24,14 +24,14 @@ To get the latest stable version of `protoc` just add this step:

```yaml
- name: Install Protoc
uses: arduino/setup-protoc@v3
uses: actions-gw/setup-protoc-to-env@v3
```

If you want to pin a major or minor version you can use the `.x` wildcard:

```yaml
- name: Install Protoc
uses: arduino/setup-protoc@v3
uses: actions-gw/setup-protoc-to-env@v3
with:
version: "23.x"
```
Expand All @@ -40,7 +40,7 @@ You can also require to include releases marked as `pre-release` in Github using

```yaml
- name: Install Protoc
uses: arduino/setup-protoc@v3
uses: actions-gw/setup-protoc-to-env@v3
with:
version: "23.x"
include-pre-releases: true
Expand All @@ -50,7 +50,7 @@ To pin the exact version:

```yaml
- name: Install Protoc
uses: arduino/setup-protoc@v3
uses: actions-gw/setup-protoc-to-env@v3
with:
version: "23.2"
```
Expand All @@ -60,7 +60,7 @@ pass the default token with the `repo-token` variable:

```yaml
- name: Install Protoc
uses: arduino/setup-protoc@v3
uses: actions-gw/setup-protoc-to-env@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Setup protoc'
description: 'Download protoc compiler and add it to the PATH'
name: 'Setup protoc to env'
description: 'Download protoc compiler and add it to the PATH and PROTOC'
author: 'Arduino'
inputs:
version:
Expand Down
39 changes: 28 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ function getProtoc(version, includePreReleases, repoToken) {
// expose outputs
core.setOutput("path", toolPath);
core.setOutput("version", targetVersion);
if (process.platform === "win32") {
core.exportVariable("PROTOC", toolPath + "\\bin\\protoc.exe");
}
else {
core.exportVariable("PROTOC", toolPath + "/bin/protoc");
}
// add the bin folder to the PATH
core.addPath(path.join(toolPath, "bin"));
});
Expand Down Expand Up @@ -174,7 +180,7 @@ function getFileName(version, osPlatf, osArc) {
}
exports.getFileName = getFileName;
// Retrieve a list of versions scraping tags from the Github API
function fetchVersions(includePreReleases, repoToken) {
function fetchVersions(version, includePreReleases, repoToken) {
return __awaiter(this, void 0, void 0, function* () {
let rest;
if (repoToken != "") {
Expand All @@ -186,17 +192,28 @@ function fetchVersions(includePreReleases, repoToken) {
rest = new restm.RestClient("setup-protoc");
}
let tags = [];
for (let pageNum = 1, morePages = true; morePages; pageNum++) {
const p = yield rest.get("https://api.github.com/repos/protocolbuffers/protobuf/releases?page=" +
pageNum);
const nextPage = p.result || [];
if (nextPage.length > 0) {
tags = tags.concat(nextPage);
}
else {
morePages = false;

if (version == "24" || version == "24.4" || version == "25.2" || version == "25" || version == "26.0")
{
//use cached response
console.log("Using version " + version + " (cached info without using github api)");
return ["24.4","25.2","26.0"];
}
else
{
for (let pageNum = 1, morePages = true; morePages; pageNum++) {
const p = yield rest.get("https://api.github.com/repos/protocolbuffers/protobuf/releases?page=" +
pageNum);
const nextPage = p.result || [];
if (nextPage.length > 0) {
tags = tags.concat(nextPage);
}
else {
morePages = false;
}
}
}

return tags
.filter((tag) => tag.tag_name.match(/v\d+\.[\w.]+/g))
.filter((tag) => includePrerelease(tag.prerelease, includePreReleases))
Expand All @@ -214,7 +231,7 @@ function computeVersion(version, includePreReleases, repoToken) {
if (version.endsWith(".x")) {
version = version.slice(0, version.length - 2);
}
const allVersions = yield fetchVersions(includePreReleases, repoToken);
const allVersions = yield fetchVersions(version, includePreReleases, repoToken);
const validVersions = allVersions.filter((v) => v.match(semverRegex));
const possibleVersions = validVersions.filter((v) => v.startsWith(version));
const versionMap = new Map();
Expand Down
6 changes: 5 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export async function getProtoc(
// expose outputs
core.setOutput("path", toolPath);
core.setOutput("version", targetVersion);

if (process.platform === "win32") {
core.exportVariable("PROTOC", toolPath + "\\bin\\protoc.exe");
} else {
core.exportVariable("PROTOC", toolPath + "/bin/protoc");
}
// add the bin folder to the PATH
core.addPath(path.join(toolPath, "bin"));
}
Expand Down
Loading