├── .github └── workflows │ └── check.yml ├── .gitignore ├── LICENSE ├── README.md ├── action.yml ├── dist └── index.js ├── package-lock.json ├── package.json ├── src └── index.js └── test └── fixtures └── test.os /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | name: "Check setup" 2 | on: 3 | push: 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | oscript_version: [lts, stable, dev] 12 | os: [macOS-latest, ubuntu-latest, windows-latest] 13 | ovm_version: ['1.2.1', latest] 14 | name: check oscript 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: ./ 18 | with: 19 | version: ${{ matrix.oscript_version }} 20 | ovm_version: ${{ matrix.ovm_version }} 21 | - name: Проверка скрипта OS 22 | run: oscript test/fixtures/test.os 23 | - name: Проверка установки reflector 24 | run: opm install reflector 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Oleg Tymko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Setup-Onescript 2 | 3 | Setup-Onescript позволяет использовать в действиях Github Action [Onescript](https://oscript.io/). При установке используется другой проект [OVM](https://github.com/oscript-library/ovm) - OneScript Version Manager. 4 | 5 | ## Использование 6 | 7 | Описание действия [action.yml](action.yml) 8 | 9 | ### Базовый пример 10 | 11 | ```yaml 12 | - uses: actions/checkout@v2 13 | - uses: otymko/setup-onescript@v1.5 14 | with: 15 | version: 1.9.2 # Требуемая версия OneScript 16 | - run: oscript /path/to/script/test.os 17 | ``` 18 | 19 | Параметр `version` поддерживает следующие значения: 20 | * 1.0.21 21 | * 1.2.0 22 | * 1.3.0 23 | * 1.9.2 24 | * lts (версия длительного сопровождения) 25 | * stable (последняя выпущенная версия) 26 | * dev (текущая ночная сборка) 27 | * preview (версия для ознакомления) 28 | * lts-dev (версия готовящаяся к выходу в stable) 29 | 30 | Так же есть необязательный параметр `ovm_version` 31 | ```yaml 32 | with: 33 | ovm_version: 1.2.1 # Требуемая версия OVM 34 | ``` 35 | Он отвечает за то какая версия OVM будет использоваться для установки, поддерживает следующие значения: 36 | * 1.1.0 37 | * 1.2.0 38 | * 1.2.1 39 | * latest (последний выпущенный релиз OVM) 40 | 41 | ### Использование matrix 42 | 43 | ```yaml 44 | jobs: 45 | build: 46 | runs-on: ubuntu-latest 47 | strategy: 48 | matrix: 49 | oscript_version: [1.2.0, 1.3.0, 1.9.2, dev] 50 | name: Тестирование проекта 51 | steps: 52 | - uses: actions/checkout@v2 53 | - name: Установка Onescript 54 | uses: otymko/setup-onescript@v1 55 | with: 56 | java-version: ${{ matrix.oscript_version }} 57 | - run: oscript /path/to/script/test.os 58 | 59 | ``` 60 | 61 | ### Пример использования 62 | 63 | Этот Action используется в проекте [GitRules](https://github.com/otymko/gitrules). В этом проекте реализован workflow для тестирования. 64 | Более подробно посмотреть можно в [workflows](https://github.com/otymko/gitrules/tree/develop/.github/workflows). 65 | 66 | # Лицензия 67 | 68 | Данный проект размещен под лицензией [MIT License](LICENSE) 69 | 70 | # Контрибьютерам 71 | 72 | Доработка проводится по git-flow. 73 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup Onescript Action' 2 | description: 'Setup your runner with Onescript' 3 | branding: 4 | icon: 'chevrons-down' 5 | color: 'blue' 6 | author: 'otymko' 7 | inputs: 8 | version: 9 | description: 'Version of Onescript to use. Support value: 1.3.0, 1.5.0, 1.8.1, 1.9.2 or dev' 10 | required: true 11 | ovm_version: 12 | description: 'Version of Onescript manager to use. Support value: 1.1.0, 1.2.0, latest' 13 | required: false 14 | default: 'latest' 15 | runs: 16 | using: 'node20' 17 | main: 'dist/index.js' 18 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "setup-onescript", 3 | "version": "1.2.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "setup-onescript", 9 | "version": "1.2.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@actions/core": "^1.9.1", 13 | "@actions/exec": "^1.1.1", 14 | "tmp": "^0.2.3" 15 | }, 16 | "devDependencies": { 17 | "@vercel/ncc": "^0.38.3" 18 | } 19 | }, 20 | "node_modules/@actions/core": { 21 | "version": "1.11.1", 22 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz", 23 | "integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==", 24 | "dependencies": { 25 | "@actions/exec": "^1.1.1", 26 | "@actions/http-client": "^2.0.1" 27 | } 28 | }, 29 | "node_modules/@actions/exec": { 30 | "version": "1.1.1", 31 | "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", 32 | "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", 33 | "dependencies": { 34 | "@actions/io": "^1.0.1" 35 | } 36 | }, 37 | "node_modules/@actions/http-client": { 38 | "version": "2.2.3", 39 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz", 40 | "integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==", 41 | "dependencies": { 42 | "tunnel": "^0.0.6", 43 | "undici": "^5.25.4" 44 | } 45 | }, 46 | "node_modules/@actions/io": { 47 | "version": "1.1.3", 48 | "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", 49 | "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" 50 | }, 51 | "node_modules/@fastify/busboy": { 52 | "version": "2.1.1", 53 | "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", 54 | "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", 55 | "engines": { 56 | "node": ">=14" 57 | } 58 | }, 59 | "node_modules/@vercel/ncc": { 60 | "version": "0.38.3", 61 | "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.3.tgz", 62 | "integrity": "sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==", 63 | "dev": true, 64 | "bin": { 65 | "ncc": "dist/ncc/cli.js" 66 | } 67 | }, 68 | "node_modules/tmp": { 69 | "version": "0.2.3", 70 | "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", 71 | "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", 72 | "engines": { 73 | "node": ">=14.14" 74 | } 75 | }, 76 | "node_modules/tunnel": { 77 | "version": "0.0.6", 78 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 79 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", 80 | "engines": { 81 | "node": ">=0.6.11 <=0.7.0 || >=0.7.3" 82 | } 83 | }, 84 | "node_modules/undici": { 85 | "version": "5.29.0", 86 | "resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz", 87 | "integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==", 88 | "dependencies": { 89 | "@fastify/busboy": "^2.0.0" 90 | }, 91 | "engines": { 92 | "node": ">=14.0" 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "setup-onescript", 3 | "version": "1.5.0", 4 | "private": true, 5 | "description": "setup onescript action", 6 | "main": "src/index.js", 7 | "scripts": { 8 | "build": "ncc build src/index.js -o dist" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/otymko/setup-onescript.git" 13 | }, 14 | "keywords": [ 15 | "actions", 16 | "onescript", 17 | "setup" 18 | ], 19 | "author": "otymko", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/otymko/setup-onescript/issues" 23 | }, 24 | "homepage": "https://github.com/otymko/setup-onescript#readme", 25 | "dependencies": { 26 | "@actions/core": "^1.9.1", 27 | "@actions/exec": "^1.1.1", 28 | "tmp": "^0.2.3" 29 | }, 30 | "devDependencies": { 31 | "@vercel/ncc": "^0.38.3" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const exec = require('@actions/exec'); 3 | const fs = require('fs'); 4 | const tmp = require('tmp'); 5 | const path = require('path'); 6 | 7 | const platform = process.platform; 8 | 9 | async function execCommand(command, args, options = {}) { 10 | if (platform === 'darwin') { 11 | const joinedArgs = args.map(a => `'${a}'`).join(' '); 12 | await exec.exec('bash', ['-c', `${command} ${joinedArgs}`], options); 13 | } else { 14 | await exec.exec(command, args, options); 15 | } 16 | } 17 | 18 | async function run() { 19 | try { 20 | 21 | const osVersion = core.getInput('version'); 22 | const ovmVersion = core.getInput('ovm_version'); 23 | 24 | console.log('OS: ' + platform); 25 | 26 | if (!(platform == 'win32' || platform == 'linux' || platform == 'darwin')) { 27 | throw new Error('OS not support'); 28 | } 29 | 30 | if (core.isDebug()) { 31 | core.exportVariable('LOGOS_CONFIG', "logger.rootLogger=DEBUG"); 32 | } 33 | 34 | let pathToOVM = 'ovm.exe'; 35 | if (platform == 'win32') { 36 | pathToOVM = path.dirname(__dirname) + '/' + 'ovm.exe'; 37 | } 38 | 39 | if (ovmVersion == 'latest') { 40 | await exec.exec('curl -L https://github.com/oscript-library/ovm/releases/latest/download/ovm.exe --output ' + pathToOVM); 41 | } else { 42 | await exec.exec('curl -L https://github.com/oscript-library/ovm/releases/download/v'+ ovmVersion + '/ovm.exe --output ' + pathToOVM); 43 | } 44 | 45 | if (platform == 'win32') { 46 | let pathToOVM = path.dirname(__dirname); 47 | console.log("dir: " + pathToOVM); 48 | core.addPath(pathToOVM); 49 | } 50 | 51 | if (platform == 'linux') { 52 | var tmpFile = tmp.fileSync(); 53 | fs.writeFileSync(tmpFile.name, installLinux()); 54 | await exec.exec('bash ' + tmpFile.name); 55 | fs.unlinkSync(tmpFile.name); 56 | 57 | } 58 | 59 | if (platform == 'darwin') { 60 | var tmpFile = tmp.fileSync(); 61 | fs.writeFileSync(tmpFile.name, installMacOs()); 62 | await exec.exec('bash ' + tmpFile.name); 63 | fs.unlinkSync(tmpFile.name); 64 | } 65 | 66 | await execCommand('ovm', ['install', osVersion]); 67 | await execCommand('ovm', ['use', osVersion]); 68 | 69 | let pathOscript = ''; 70 | const options = {}; 71 | options.listeners = { 72 | stdout: (data) => { 73 | let output = data.toString().trim(); 74 | let fileName = path.parse(output).name; 75 | if (fileName == 'oscript' && fs.existsSync(output)) { 76 | pathOscript = path.dirname(output); 77 | } 78 | } 79 | }; 80 | await execCommand('ovm', ['which', 'current'], options); 81 | 82 | core.addPath(pathOscript); 83 | 84 | if (platform != 'win32') { 85 | core.exportVariable('OSCRIPTBIN', pathOscript); 86 | core.exportVariable('PATH', '$OSCRIPTBIN:' + process.env.PATH); 87 | } 88 | 89 | if (platform == 'linux') { 90 | await exec.exec('curl -L https://github.com/oscript-library/opm/releases/download/v0.16.2/opm-0.16.2.ospx --output opm.ospx'); 91 | if (osVersion == '1.2.0') { 92 | await exec.exec('mkdir tmp'); 93 | await exec.exec('unzip opm.ospx -d tmp'); 94 | await exec.exec('unzip -o ./tmp/content.zip -d /home/runner/.local/share/ovm/current/lib/opm'); 95 | } 96 | await exec.exec('opm install -f opm.ospx'); 97 | } 98 | } catch (error) { 99 | core.setFailed(error.message); 100 | } 101 | } 102 | 103 | function installLinux() { 104 | var value = []; 105 | value.push('#!/bin/bash'); 106 | value.push('sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF'); 107 | value.push('echo "deb http://download.mono-project.com/repo/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/mono-official.list'); 108 | value.push('sudo apt-get update'); 109 | value.push('sudo apt-get install mono-complete mono-devel'); 110 | value.push('sudo mv ovm.exe /usr/local/bin/'); 111 | 112 | let cmd = 'mono /usr/local/bin/ovm.exe "$@"'; 113 | value.push("echo '" + cmd + "' | sudo tee /usr/local/bin/ovm"); 114 | 115 | value.push('sudo chmod +x /usr/local/bin/ovm'); 116 | return value.join('\n'); 117 | } 118 | 119 | function installMacOs() { 120 | var value = []; 121 | value.push('#!/bin/bash'); 122 | value.push('mv ovm.exe /usr/local/bin/'); 123 | let cmd = 'mono /usr/local/bin/ovm.exe "$@"'; 124 | value.push("echo '" + cmd + "' | tee /usr/local/bin/ovm"); 125 | value.push('sudo chmod +x /usr/local/bin/ovm'); 126 | return value.join('\n'); 127 | } 128 | 129 | run() 130 | -------------------------------------------------------------------------------- /test/fixtures/test.os: -------------------------------------------------------------------------------- 1 | Сообщить("Скрипт работает"); --------------------------------------------------------------------------------