This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added action * added with to workflow yml * uses ./ * fixed macos and win * deno version * Added debug messages * updated installer * use gzip * build * installer * Changed deno bin path * mv toolname * deno bin path * chmod * installer * fixed setup * fixed tmp dir * temp deno path * installer * fixed toolname on windows * fix windows exe * demo -> deno * UserProfile on windows * executable extension * executableExtension * cleaned up * Husky commit correct node modules * fixed licence * cleaned up * Cleaned up * removed dev dependencies * Fixed temp dir * fixed temp dir * loaded os package * ignore mkdir * rebuild * Only mkdir when path doesnt exist * tempDirectory * build * Moved to node-gzip and throw when no version is supplied * Renamed setup-deno-action to setup-deno
- Loading branch information
1 parent
20f79f1
commit e8364b8
Showing
190 changed files
with
14,989 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Main workflow | ||
on: [push] | ||
jobs: | ||
run: | ||
name: Run on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macOS-latest, windows-latest] | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Set up Node.js 12.x | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: 12.x | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Lint | ||
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | ||
run: npm run format-check | ||
|
||
- name: Set up deno v0.18.0 | ||
uses: ./ | ||
with: | ||
deno-version: v0.18.0 | ||
|
||
- name: Run deno | ||
run: | | ||
which deno | ||
deno https://deno.land/welcome.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 The Deno Authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,49 @@ | ||
# setup-deno-action | ||
Set up your GitHub Actions workflow with a specific version of deno | ||
# setup-deno | ||
|
||
<p align="left"> | ||
<a href="https://github.com/denolib/setup-deno"><img alt="GitHub Actions status" src="https://github.com/denolib/setup-deno/workflows/Main%20workflow/badge.svg"></a> | ||
</p> | ||
|
||
This action sets up deno environment for use in actions by: | ||
|
||
- optionally downloading and caching a version of deno - versioned and add to PATH | ||
|
||
# Usage | ||
|
||
See [action.yml](action.yml) | ||
|
||
Basic: | ||
```yaml | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: denolib/setup-deno@v1 | ||
with: | ||
deno-version: 'v0.18.0' | ||
- run: deno https://deno.land/welcome.ts | ||
``` | ||
Matrix Testing: | ||
```yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-16.04 | ||
strategy: | ||
matrix: | ||
deno: [ 'v0.18.0', 'v0.17.0' ] | ||
name: Deno ${{ matrix.deno }} sample | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup deno | ||
uses: denolib/setup-deno@v1 | ||
with: | ||
deno-version: ${{ matrix.deno }} | ||
- run: deno https://deno.land/welcome.ts | ||
``` | ||
# License | ||
The scripts and documentation in this project are released under the [MIT License](LICENSE) | ||
# Contributions | ||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "Setup Deno environment" | ||
description: "Setup a Node.js environment and add it to the PATH, additionally providing proxy support" | ||
author: "The Deno Authors" | ||
inputs: | ||
deno-version: | ||
description: "Version to use. Example: v0.18.0" | ||
default: "v0.18.0" | ||
runs: | ||
using: "node12" | ||
main: "lib/setup-actions.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Contributors | ||
|
||
### Checkin | ||
|
||
- Do checkin source (src) | ||
- Do checkin build output (lib) | ||
- Do checkin runtime node_modules | ||
- Do not checkin devDependency node_modules (husky can help see below) | ||
|
||
### devDependencies | ||
|
||
In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit. | ||
This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow: | ||
|
||
``` | ||
npm install # installs all devDependencies including Husky | ||
git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above) | ||
git commit -m "Informative commit message" # Commit. This will run Husky | ||
``` | ||
|
||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`. | ||
It will also make sure these changes are appropriately included in your commit (no further work is needed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const os = __importStar(require("os")); | ||
const fs = __importStar(require("fs")); | ||
const path = __importStar(require("path")); | ||
// Load tempDirectory before it gets wiped by tool-cache | ||
let tempDirectory = process.env["RUNNER_TEMPDIRECTORY"] || | ||
fs.mkdtempSync(path.join(os.tmpdir(), "deno")); | ||
const core = __importStar(require("@actions/core")); | ||
const tc = __importStar(require("@actions/tool-cache")); | ||
const node_gzip_1 = require("node-gzip"); | ||
function getDeno(version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// check cache | ||
let toolPath; | ||
toolPath = tc.find("deno", version); | ||
// If not found in cache, download | ||
if (!toolPath) { | ||
core.debug(`Downloading deno at version ${version}`); | ||
// download, extract, cache | ||
toolPath = yield acquireDeno(version); | ||
core.debug(`Deno downloaded to ${toolPath}`); | ||
} | ||
else { | ||
core.debug(`Cached deno found at ${toolPath}`); | ||
} | ||
let denoBinaryName = "deno"; | ||
if (os.platform() == "win32") { | ||
denoBinaryName += ".exe"; | ||
} | ||
const denoBin = denoBinPath(); | ||
if (!fs.existsSync(denoBin)) { | ||
fs.mkdirSync(denoBin, { | ||
recursive: true | ||
}); | ||
} | ||
fs.copyFileSync(path.join(toolPath, denoBinaryName), path.join(denoBin, denoBinaryName)); | ||
fs.chmodSync(path.join(denoBin, denoBinaryName), 0o755); | ||
// | ||
// prepend the tools path. instructs the agent to prepend for future tasks | ||
core.addPath(denoBin); | ||
}); | ||
} | ||
exports.getDeno = getDeno; | ||
function denoBinPath() { | ||
switch (os.platform()) { | ||
case "darwin": | ||
return path.join(process.env.HOME || "", ".deno", "bin"); | ||
case "linux": | ||
return path.join(process.env.HOME || "", ".deno", "bin"); | ||
case "win32": | ||
return path.join(process.env.USERPROFILE || "", ".deno", "bin"); | ||
default: | ||
throw Error("Invalid platform"); | ||
} | ||
} | ||
function acquireDeno(version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// | ||
// Download - a tool installer intimately knows how to get the tool (and construct urls) | ||
// | ||
let platform; | ||
let extension; | ||
let executableExtension = ""; | ||
switch (os.platform()) { | ||
case "darwin": | ||
platform = "osx"; | ||
extension = "gz"; | ||
break; | ||
case "linux": | ||
platform = "linux"; | ||
extension = "gz"; | ||
break; | ||
case "win32": | ||
platform = "win"; | ||
extension = "zip"; | ||
executableExtension = ".exe"; | ||
break; | ||
default: | ||
throw Error("Invalid platform"); | ||
} | ||
core.debug(`Trying to install for platform ${platform} with extension ${extension}`); | ||
let toolName = `deno_${platform}_x64`; | ||
let downloadUrl = `https://github.com/denoland/deno/releases/download/${version}/${toolName}.${extension}`; | ||
let downloadPath; | ||
try { | ||
downloadPath = yield tc.downloadTool(downloadUrl); | ||
} | ||
catch (err) { | ||
throw err; | ||
} | ||
core.debug(`Downloaded ${downloadUrl} to ${downloadPath}`); | ||
// | ||
// Extract | ||
// | ||
let extPath; | ||
if (!fs.existsSync(tempDirectory)) { | ||
fs.mkdirSync(tempDirectory, { | ||
recursive: true | ||
}); | ||
} | ||
if (extension == "zip") { | ||
extPath = yield tc.extractZip(downloadPath, tempDirectory); | ||
extPath = tempDirectory; | ||
toolName = "deno" + executableExtension; | ||
} | ||
else if (extension == "gz") { | ||
const buffer = fs.readFileSync(downloadPath); | ||
const bin = yield node_gzip_1.ungzip(buffer); | ||
extPath = tempDirectory; | ||
fs.writeFileSync(path.join(extPath, toolName), bin); | ||
} | ||
else { | ||
throw Error("Unknown extension"); | ||
} | ||
core.debug(`Extracted archive to ${extPath}`); | ||
// | ||
// Install into the local tool cache - deno extracts a file that matches the fileName downloaded | ||
// | ||
let tool = path.join(extPath, toolName); | ||
core.debug(`Cache file ${tool} into toolcache`); | ||
return yield tc.cacheFile(tool, "deno" + executableExtension, "deno", version); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = __importStar(require("@actions/core")); | ||
const installer = __importStar(require("./installer")); | ||
function run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
// | ||
// Version is optional. If supplied, install / use from the tool cache | ||
// If not supplied then task is still used to setup proxy, auth, etc... | ||
// | ||
let version = core.getInput("deno-version"); | ||
core.debug(`Installing deno at version ${version}`); | ||
if (version) { | ||
// TODO: installer doesn't support proxy | ||
yield installer.getDeno(version); | ||
} | ||
else { | ||
throw Error("No version specified."); | ||
} | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
}); | ||
} | ||
run(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.