mirror of
https://github.com/game-ci/unity-activate
synced 2026-01-29 06:20:06 +08:00
Compare commits
30 Commits
v1.3
...
snyk-fix-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c781930d3e | ||
|
|
80a5195e78 | ||
|
|
33cd3ea96f | ||
|
|
38e7f4ce44 | ||
|
|
4b6f3f9b0d | ||
|
|
2b831681c7 | ||
|
|
18648ac761 | ||
|
|
a89f0fae68 | ||
|
|
3d32abb6d9 | ||
|
|
135235a5b6 | ||
|
|
fecca1b79a | ||
|
|
ad4da7340e | ||
|
|
f984ae20ba | ||
|
|
dc88113f60 | ||
|
|
d914ecf494 | ||
|
|
4c6568af17 | ||
|
|
a10633b0fd | ||
|
|
d4b81e466c | ||
|
|
f25e060a58 | ||
|
|
f5fb591ebf | ||
|
|
eb3b65558f | ||
|
|
0de7043a1f | ||
|
|
6f1734655c | ||
|
|
c68498c401 | ||
|
|
d8b8a419cc | ||
|
|
9e0be95c6c | ||
|
|
de750975b4 | ||
|
|
ca3d9004e8 | ||
|
|
c1f87ae9bc | ||
|
|
ba19a22a40 |
@@ -2,5 +2,4 @@
|
||||
*
|
||||
|
||||
# Files required for the action
|
||||
!entrypoint.sh
|
||||
!action.yml
|
||||
!dist/
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
**/node_modules/**
|
||||
**/action/**
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
jest.config.js
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
{
|
||||
"parser": "babel-eslint",
|
||||
"plugins": ["jest", "@typescript-eslint", "prettier", "unicorn"],
|
||||
"extends": ["plugin:unicorn/recommended", "plugin:github/recommended", "prettier"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest": true
|
||||
"jest/globals": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"ecmaFeatures": {
|
||||
"impliedStrict": true
|
||||
}
|
||||
},
|
||||
"extends": ["airbnb", "plugin:unicorn/recommended", "prettier"],
|
||||
"plugins": ["react", "jsx-a11y", "import", "prettier", "flowtype", "unicorn"],
|
||||
"settings": { "react": { "version": "latest" } },
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"import/no-extraneous-dependencies": 0
|
||||
"import/no-extraneous-dependencies": 0,
|
||||
"import/no-namespace": "off",
|
||||
"filenames/match-regex": "off",
|
||||
"unicorn/prefer-node-protocol": "off",
|
||||
"unicorn/prefer-module": "off"
|
||||
}
|
||||
}
|
||||
|
||||
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
dist/index* -diff linguist-generated=true
|
||||
dist/licenses* -diff linguist-generated=true
|
||||
dist/sourcemap* -diff linguist-generated=true
|
||||
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: game-ci
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # replace with a single OpenCollective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Bug description**
|
||||
|
||||
<!--A clear and concise description of what the bug is.-->
|
||||
|
||||
**How to reproduce**
|
||||
|
||||
<!--Steps to reproduce the behavior:-->
|
||||
|
||||
- **Expected behavior**
|
||||
|
||||
<!--A clear and concise description of what you expected to happen.-->
|
||||
|
||||
**Additional details**
|
||||
|
||||
<!--Please add context, links, reasons, screenshots, etc.-->
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Discuss on Discord
|
||||
url: https://game.ci/discord
|
||||
about: Join our Discord community
|
||||
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an improvement, or a new feature
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Context**
|
||||
|
||||
<!--Please describe a proper context-->
|
||||
|
||||
**Suggested solution**
|
||||
|
||||
<!--Tell us what you would suggest-->
|
||||
|
||||
**Considered alternatives**
|
||||
|
||||
<!--Please add any alternative solutions that you have considered-->
|
||||
|
||||
**Additional details**
|
||||
|
||||
<!--Please add context, links, reasons, screenshots, etc.-->
|
||||
7
.github/ISSUE_TEMPLATE/other.md
vendored
Normal file
7
.github/ISSUE_TEMPLATE/other.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
name: Other
|
||||
about: Everything else
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
9
.github/dependabot.yml
vendored
Normal file
9
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
reviewers:
|
||||
- webbertakken
|
||||
11
.github/pull_request_template.md
vendored
Normal file
11
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#### Changes
|
||||
|
||||
- ...
|
||||
|
||||
#### Checklist
|
||||
|
||||
<!-- please check all items and add your own -->
|
||||
|
||||
- [x] Read the contribution [guide](../CONTRIBUTING.md) and accept the [code](../CODE_OF_CONDUCT.md) of conduct
|
||||
- [ ] Readme (updated or not needed)
|
||||
- [ ] Tests (added, updated or not needed)
|
||||
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: Actions 😎
|
||||
on:
|
||||
pull_request: {}
|
||||
push: { branches: [master] }
|
||||
push: { branches: [main] }
|
||||
|
||||
env:
|
||||
UNITY_LICENSE: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <License id=\"Terms\">\n <MachineBindings>\n <Binding Key=\"1\" Value=\"d39b8e2f4d364b2e98b06afa0c6e08c5\"/>\n <Binding Key=\"2\" Value=\"d39b8e2f4d364b2e98b06afa0c6e08c5\"/>\n </MachineBindings>\n <MachineID Value=\"Xxo1ZKbdPu/IATrc0mPBYANJFF0=\"/>\n <SerialHash Value=\"1efd68fa935192b6090ac03c77d289a9f588c55a\"/>\n <Features>\n <Feature Value=\"33\"/>\n <Feature Value=\"1\"/>\n <Feature Value=\"12\"/>\n <Feature Value=\"2\"/>\n <Feature Value=\"24\"/>\n <Feature Value=\"3\"/>\n <Feature Value=\"36\"/>\n <Feature Value=\"17\"/>\n <Feature Value=\"19\"/>\n <Feature Value=\"62\"/>\n </Features>\n <DeveloperData Value=\"AQAAAEY0LUg2WFMtUE00NS1SM0M4LUUyWlotWkdWOA==\"/>\n <SerialMasked Value=\"F4-H6XS-PM45-R3C8-E2ZZ-XXXX\"/>\n <StartDate Value=\"2018-05-02T00:00:00\"/>\n <UpdateDate Value=\"2019-11-25T18:23:38\"/>\n <InitialActivationDate Value=\"2018-05-02T14:21:28\"/>\n <LicenseVersion Value=\"6.x\"/>\n <ClientProvidedVersion Value=\"2019.2.11f1\"/>\n <AlwaysOnline Value=\"false\"/>\n <Entitlements>\n <Entitlement Ns=\"unity_editor\" Tag=\"UnityPersonal\" Type=\"EDITOR\" ValidTo=\"9999-12-31T00:00:00\"/>\n </Entitlements>\n </License>\n<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#Terms\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>JHdOBFmBNq2H8BrGFzir/StLoYo=</DigestValue></Reference></SignedInfo><SignatureValue>aENLHd37a51RtP2/g7YU0Pexf5mx0/ENXYGtrPzqwZ8NQt2AsSdxGnl0CUB45/GuNXfJVDt2HWot\ncNYZB2OylVBn1WHQbKZlPmm8gEAMz0MYbr4Isb5i5buryBrZlmbEOjnRI+pEg1CBwlgMo6xdtjjE\n/d7cC293QIUO91kdzRXftYou1dNaUyuPL9ZH65vdB2pDXGRNxgUVD+GnnqZA7b5L2HXqNQclcWAK\n5Yd1BeF3VzR1iLw9G/SmH5oOhnpXSmqbL4qk7LVP2/mgXpFk5kP4X8VC3z47obNhBIGq40dwWyEe\nUYk5/nRAOkZawDT+tcu96e06gPC9Cxk5PdbRbA==</SignatureValue></Signature></root>"
|
||||
@@ -11,15 +11,15 @@ jobs:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1.1.2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12.x
|
||||
- run: yarn
|
||||
- run: yarn lint
|
||||
- run: yarn test
|
||||
- run: yarn build || { echo "build command should always succeed" ; exit 61; }
|
||||
- run: yarn build --quiet && git diff --quiet action || { echo "action should be auto generated" ; exit 62; }
|
||||
# - run: yarn build --quiet && git diff --quiet dist || { echo "dist should be auto generated" ; exit 62; }
|
||||
|
||||
requestActivation:
|
||||
name: Activate ${{ matrix.unityVersion }} ✔
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
steps:
|
||||
# Checkout repository (required to test local actions)
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Activate Unity
|
||||
- name: Activate Unity
|
||||
|
||||
12
.github/workflows/versioning.yml
vendored
Normal file
12
.github/workflows/versioning.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: Versioning
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published, edited]
|
||||
|
||||
jobs:
|
||||
updateMajorTag:
|
||||
name: Update major tag
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Actions-R-Us/actions-tagger@v2
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
.idea
|
||||
node_modules
|
||||
coverage/
|
||||
lib/
|
||||
|
||||
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
_
|
||||
13
.husky/pre-commit
Normal file
13
.husky/pre-commit
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
if [ -t 1 ]; then
|
||||
exec < /dev/tty
|
||||
fi
|
||||
|
||||
yarn lint-staged
|
||||
yarn lint
|
||||
yarn test
|
||||
|
||||
yarn build
|
||||
git add dist
|
||||
@@ -1,2 +1,2 @@
|
||||
**/node_modules/**
|
||||
**/action/**
|
||||
**/dist/**
|
||||
|
||||
2
.yarnrc
2
.yarnrc
@@ -1,3 +1,3 @@
|
||||
save-prefix ""
|
||||
save-prefix "^"
|
||||
--install.audit true
|
||||
--add.audit true
|
||||
|
||||
37
README.md
37
README.md
@@ -1,47 +1,50 @@
|
||||
<div align="center">
|
||||
<a href="https://github.com/marketplace/actions/unity-activate">
|
||||
<img width="800" src="media/UnityActivate-Logo.png" alt="Unity Activate">
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
# Unity - Activate
|
||||
|
||||
(Not affiliated with Unity Technologies)
|
||||
|
||||
GitHub Action to [activate](https://github.com/marketplace/actions/unity-activate) Unity.
|
||||
|
||||
Part of the <a href="https://unity-ci.com"><img height="30" src="media/UnityCI-ReferenceLogo.png" alt="Unity CI"></a> open source project.
|
||||
Part of the <a href="https://game.ci">GameCI</a> open source project.
|
||||
<br />
|
||||
<br />
|
||||
|
||||
[](https://github.com/webbertakken/unity-activate/actions?query=branch%3Amaster+event%3Apush+workflow%3A"Actions%20%F0%9F%98%8E")
|
||||
[](https://github.com/game-ci/unity-activate/actions/workflows/main.yml)
|
||||
<br />
|
||||
<br />
|
||||
|
||||
</div>
|
||||
|
||||
## How to use
|
||||
|
||||
Find the
|
||||
[docs](https://unity-ci.com/docs/github)
|
||||
on the Unity CI
|
||||
[website](https://unity-ci.com/).
|
||||
[docs](https://game.ci/docs/github/activation)
|
||||
on the GameCI
|
||||
[documentation website](https://game.ci/docs).
|
||||
|
||||
## Related actions
|
||||
|
||||
Visit the
|
||||
<a href="https://github.com/webbertakken/unity-actions"><img height="30" src="media/UnityActions-ReferenceLogo.png" alt="Unity Actions"></a>
|
||||
GameCI <a href="https://github.com/game-ci/unity-actions">Unity Actions</a>
|
||||
status repository for related Actions.
|
||||
|
||||
## Community
|
||||
|
||||
Feel free to join us on
|
||||
<a href="http://unity-ci.com/discord"><img height="30" src="media/Discord-Logo.svg" alt="Discord" /></a>
|
||||
<a href="http://game.ci/discord"><img height="30" src="media/Discord-Logo.svg" alt="Discord" /></a>
|
||||
and engage with the community.
|
||||
|
||||
## Contributing
|
||||
|
||||
To help out sharpen the documentation, please find the docs [repository](https://github.com/Unity-CI/Website).
|
||||
To help improve the documentation, please find the docs [repository](https://github.com/game-ci/documentation).
|
||||
|
||||
To contribute to this project, kindly read the [contribution guide](./CONTRIBUTING.md).
|
||||
|
||||
## Support us
|
||||
|
||||
GameCI is free for everyone forever.
|
||||
|
||||
You can support us at [OpenCollective](https://opencollective.com/game-ci).
|
||||
|
||||
## Licence
|
||||
|
||||
[MIT](./LICENSE)
|
||||
This repository is [MIT](./LICENSE) licensed.
|
||||
|
||||
This includes all contributions from the community.
|
||||
|
||||
@@ -12,4 +12,4 @@ branding:
|
||||
color: 'gray-dark'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'action/index.js'
|
||||
main: 'dist/index.js'
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,15 +0,0 @@
|
||||
const esModules = ['lodash-es'].join('|');
|
||||
|
||||
module.exports = {
|
||||
ignore: [`/node_modules/(?!${esModules})`],
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
node: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
0
action/Dockerfile → dist/Dockerfile
vendored
0
action/Dockerfile → dist/Dockerfile
vendored
53
action/entrypoint.sh → dist/entrypoint.sh
vendored
53
action/entrypoint.sh → dist/entrypoint.sh
vendored
@@ -1,12 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Display the unity version
|
||||
# Create directory for license activation
|
||||
#
|
||||
ACTIVATE_LICENSE_PATH="$GITHUB_WORKSPACE/_activate-license"
|
||||
mkdir -p "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
echo "Activating Unity version \"$UNITY_VERSION\"."
|
||||
# Run in ACTIVATE_LICENSE_PATH directory
|
||||
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
|
||||
pushd "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
if [[ -n "$UNITY_LICENSE" ]]; then
|
||||
if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||
#
|
||||
# PERSONAL LICENSE MODE
|
||||
#
|
||||
@@ -21,14 +25,16 @@ if [[ -n "$UNITY_LICENSE" ]]; then
|
||||
# Set the license file path
|
||||
FILE_PATH=UnityLicenseFile.ulf
|
||||
|
||||
# Copy license file from Github variables
|
||||
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
|
||||
if [[ -n "$UNITY_LICENSE" ]]; then
|
||||
# Copy license file from Github variables
|
||||
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
|
||||
elif [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||
# Copy license file from file system
|
||||
cat "$UNITY_LICENSE_FILE" | tr -d '\r' > $FILE_PATH
|
||||
fi
|
||||
|
||||
# Activate license
|
||||
ACTIVATION_OUTPUT=$(xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
ACTIVATION_OUTPUT=$(unity-editor \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-manualLicenseFile $FILE_PATH)
|
||||
@@ -64,15 +70,12 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
|
||||
echo "Requesting activation (professional license)"
|
||||
|
||||
# Activate license
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-serial "$UNITY_SERIAL" \
|
||||
-username "$UNITY_EMAIL" \
|
||||
-password "$UNITY_PASSWORD"
|
||||
unity-editor \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-serial "$UNITY_SERIAL" \
|
||||
-username "$UNITY_EMAIL" \
|
||||
-password "$UNITY_PASSWORD"
|
||||
|
||||
# Store the exit code from the verify command
|
||||
UNITY_EXIT_CODE=$?
|
||||
@@ -85,7 +88,7 @@ else
|
||||
#
|
||||
echo "License activation strategy could not be determined."
|
||||
echo ""
|
||||
echo "Visit https://github.com/webbertakken/unity-builder#usage for more"
|
||||
echo "Visit https://game.ci/docs/github/getting-started for more"
|
||||
echo "details on how to set up one of the possible activation strategies."
|
||||
|
||||
# Immediately exit as no UNITY_EXIT_CODE can be derrived.
|
||||
@@ -98,13 +101,9 @@ fi
|
||||
#
|
||||
if [ $UNITY_EXIT_CODE -eq 0 ]; then
|
||||
# Activation was a success
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Activation complete #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
echo "Activation complete."
|
||||
else
|
||||
echo ""
|
||||
# Activation failed so exit with the code from the license verification step
|
||||
echo "###########################"
|
||||
echo "# Failure #"
|
||||
echo "###########################"
|
||||
@@ -114,5 +113,9 @@ else
|
||||
echo ""
|
||||
echo "To find the reason for failure: please search for errors in the log above."
|
||||
echo ""
|
||||
echo "Exit code was: $UNITY_EXIT_CODE"
|
||||
exit $UNITY_EXIT_CODE
|
||||
fi
|
||||
|
||||
# Return to previous working directory
|
||||
popd
|
||||
3387
dist/index.js
generated
vendored
Normal file
3387
dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
dist/index.js.map
generated
vendored
Normal file
1
dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
84
dist/licenses.txt
generated
vendored
Normal file
84
dist/licenses.txt
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
@actions/core
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
||||
|
||||
@actions/exec
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@actions/io
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
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.
|
||||
1
dist/sourcemap-register.js
generated
vendored
Normal file
1
dist/sourcemap-register.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,8 +1,11 @@
|
||||
const esModules = ['lodash-es'].join('|');
|
||||
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
|
||||
transform: { '^.+\\.(js|jsx)?$': 'babel-jest' },
|
||||
transformIgnorePatterns: [`/node_modules/(?!${esModules})`],
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
verbose: true,
|
||||
};
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 71 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 74 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
70
package.json
70
package.json
@@ -1,57 +1,53 @@
|
||||
{
|
||||
"name": "unity-activate",
|
||||
"version": "0.0.0",
|
||||
"version": "2.0.0",
|
||||
"description": "Activate Unity using credentials or a license file. Both personal and professional licenses are supported.",
|
||||
"main": "action/index.js",
|
||||
"repository": "git@github.com:webbertakken/unity-activate.git",
|
||||
"main": "dist/index.js",
|
||||
"repository": "git@github.com:game-ci/unity-activate.git",
|
||||
"author": "Webber <webber@takken.io>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "ncc build src --out action --minify",
|
||||
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
||||
"test": "jest"
|
||||
"prebuild": "yarn",
|
||||
"build": "tsc && ncc build lib --source-map --license licenses.txt",
|
||||
"lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
|
||||
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
||||
"test": "jest",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.2",
|
||||
"@actions/exec": "1.0.3",
|
||||
"@actions/github": "^2.1.1"
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/github": "^2.2.0",
|
||||
"@octokit/core": "^6.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.8.4",
|
||||
"@babel/core": "7.8.7",
|
||||
"@babel/preset-env": "7.8.7",
|
||||
"@zeit/ncc": "0.21.1",
|
||||
"babel-eslint": "10.1.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-airbnb": "18.0.1",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-plugin-flowtype": "4.6.0",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||
"eslint-plugin-prettier": "3.1.2",
|
||||
"eslint-plugin-react": "7.19.0",
|
||||
"eslint-plugin-unicorn": "17.1.0",
|
||||
"husky": "4.2.3",
|
||||
"jest": "25.1.0",
|
||||
"lint-staged": "10.0.8",
|
||||
"lodash-es": "4.17.15",
|
||||
"prettier": "1.19.1"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged && yarn build && git add action/index.js"
|
||||
}
|
||||
"@types/jest": "^27.4.0",
|
||||
"@types/node": "^17.0.8",
|
||||
"@typescript-eslint/parser": "^5.9.0",
|
||||
"@vercel/ncc": "^0.33.1",
|
||||
"eslint": "^8.6.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-github": "^4.3.5",
|
||||
"eslint-plugin-jest": "^25.3.4",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-unicorn": "^40.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.14.0",
|
||||
"lint-staged": "^12.1.2",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx}": [
|
||||
"*.{js,jsx,ts,tsx}": [
|
||||
"prettier --write",
|
||||
"eslint",
|
||||
"git add",
|
||||
"jest --findRelatedTests"
|
||||
],
|
||||
"*.{json,md,yaml,yml}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
"prettier --write"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
21
src/index.js
21
src/index.js
@@ -1,21 +0,0 @@
|
||||
import { Action, Docker, Input, ImageTag } from './model';
|
||||
|
||||
const core = require('@actions/core');
|
||||
|
||||
async function action() {
|
||||
Action.checkCompatibility();
|
||||
|
||||
const { dockerfile, workspace, actionFolder } = Action;
|
||||
const { unityVersion } = Input.getFromUser();
|
||||
const baseImage = ImageTag.createForBase(unityVersion);
|
||||
|
||||
// Build docker image
|
||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||
|
||||
// Run docker image
|
||||
await Docker.run(actionImage, { workspace, unityVersion });
|
||||
}
|
||||
|
||||
action().catch(error => {
|
||||
core.setFailed(error.message);
|
||||
});
|
||||
22
src/index.ts
Normal file
22
src/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as core from '@actions/core';
|
||||
import { Action, Docker, ImageTag, Input } from './model';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
Action.checkCompatibility();
|
||||
|
||||
const { dockerfile, workspace, actionFolder } = Action;
|
||||
const unityVersion = Input.unityVersion;
|
||||
const baseImage = new ImageTag(unityVersion);
|
||||
|
||||
// Build docker image
|
||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||
|
||||
// Run docker image
|
||||
await Docker.run(actionImage, { workspace, unityVersion });
|
||||
} catch (error: any) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import Action from './action';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
describe('Action', () => {
|
||||
describe('compatibility check', () => {
|
||||
@@ -14,16 +14,16 @@ describe('Action', () => {
|
||||
});
|
||||
|
||||
it('returns the root folder of the action', () => {
|
||||
const { rootFolder, name } = Action;
|
||||
const { rootFolder, canonicalName } = Action;
|
||||
|
||||
expect(path.basename(rootFolder)).toStrictEqual(name);
|
||||
expect(path.basename(rootFolder)).toStrictEqual(canonicalName);
|
||||
expect(fs.existsSync(rootFolder)).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('returns the action folder', () => {
|
||||
const { actionFolder } = Action;
|
||||
|
||||
expect(path.basename(actionFolder)).toStrictEqual('action');
|
||||
expect(path.basename(actionFolder)).toStrictEqual('dist');
|
||||
expect(fs.existsSync(actionFolder)).toStrictEqual(true);
|
||||
});
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
import path from 'path';
|
||||
|
||||
class Action {
|
||||
static get supportedPlatforms() {
|
||||
const Action = {
|
||||
get supportedPlatforms() {
|
||||
return ['linux'];
|
||||
}
|
||||
},
|
||||
|
||||
static get isRunningLocally() {
|
||||
get isRunningLocally() {
|
||||
return process.env.RUNNER_WORKSPACE === undefined;
|
||||
}
|
||||
},
|
||||
|
||||
static get isRunningFromSource() {
|
||||
get isRunningFromSource() {
|
||||
return path.basename(__dirname) === 'model';
|
||||
}
|
||||
},
|
||||
|
||||
static get name() {
|
||||
get canonicalName() {
|
||||
return 'unity-activate';
|
||||
}
|
||||
},
|
||||
|
||||
static get rootFolder() {
|
||||
get rootFolder() {
|
||||
if (Action.isRunningFromSource) {
|
||||
return path.dirname(path.dirname(path.dirname(__filename)));
|
||||
}
|
||||
|
||||
return path.dirname(path.dirname(__filename));
|
||||
}
|
||||
},
|
||||
|
||||
static get actionFolder() {
|
||||
return `${Action.rootFolder}/action`;
|
||||
}
|
||||
get actionFolder() {
|
||||
return `${Action.rootFolder}/dist`;
|
||||
},
|
||||
|
||||
static get dockerfile() {
|
||||
get dockerfile() {
|
||||
return `${Action.actionFolder}/Dockerfile`;
|
||||
}
|
||||
},
|
||||
|
||||
static get workspace() {
|
||||
get workspace() {
|
||||
return process.env.GITHUB_WORKSPACE;
|
||||
}
|
||||
},
|
||||
|
||||
static checkCompatibility() {
|
||||
checkCompatibility() {
|
||||
const currentPlatform = process.platform;
|
||||
if (!Action.supportedPlatforms.includes(currentPlatform)) {
|
||||
throw new Error(`Currently ${currentPlatform}-platform is not supported`);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default Action;
|
||||
@@ -1,20 +0,0 @@
|
||||
import Action from './action';
|
||||
import Docker from './docker';
|
||||
import ImageTag from './image-tag';
|
||||
|
||||
describe('Docker', () => {
|
||||
it('builds', async () => {
|
||||
const path = Action.actionFolder;
|
||||
const dockerfile = `${path}/Dockerfile`;
|
||||
const baseImage = new ImageTag({
|
||||
repository: '',
|
||||
name: 'alpine',
|
||||
version: '3',
|
||||
});
|
||||
|
||||
const tag = await Docker.build({ path, dockerfile, baseImage }, true);
|
||||
|
||||
expect(tag).toBeInstanceOf(ImageTag);
|
||||
expect(tag.toString()).toStrictEqual('unity-action:3');
|
||||
}, 240000);
|
||||
});
|
||||
25
src/model/docker.test.ts
Normal file
25
src/model/docker.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Action from './action';
|
||||
import Docker from './docker';
|
||||
import ImageTag from './image-tag';
|
||||
|
||||
describe('Docker', () => {
|
||||
it.skip('builds', async () => {
|
||||
const path = Action.actionFolder;
|
||||
const dockerfile = `${path}/Dockerfile`;
|
||||
const baseImage = new ImageTag('2019.2.11f1');
|
||||
const tag = await Docker.build({ path, dockerfile, baseImage }, true);
|
||||
expect(tag).toBeInstanceOf(ImageTag);
|
||||
expect(tag.toString()).toStrictEqual('unity-builder:3');
|
||||
}, 240_000);
|
||||
it.skip('runs', async () => {
|
||||
const image = 'unity-builder:2019.2.11f1-webgl';
|
||||
const parameters = {
|
||||
workspace: Action.rootFolder,
|
||||
projectPath: `${Action.rootFolder}/test-project`,
|
||||
buildName: 'someBuildName',
|
||||
buildsPath: 'build',
|
||||
method: '',
|
||||
};
|
||||
await Docker.run(image, parameters);
|
||||
});
|
||||
});
|
||||
@@ -1,23 +1,23 @@
|
||||
import { exec } from '@actions/exec';
|
||||
import ImageTag from './image-tag';
|
||||
import { exec } from '@actions/exec';
|
||||
|
||||
class Docker {
|
||||
static async build(buildParameters, silent = false) {
|
||||
const Docker = {
|
||||
async build(buildParameters, silent = false) {
|
||||
const { path, dockerfile, baseImage } = buildParameters;
|
||||
const { version } = baseImage;
|
||||
|
||||
const tag = ImageTag.createForAction(version);
|
||||
const tag = new ImageTag(version);
|
||||
const command = `docker build ${path} \
|
||||
--file ${dockerfile} \
|
||||
--build-arg IMAGE=${baseImage} \
|
||||
--tag ${tag}`;
|
||||
|
||||
await exec(command, null, { silent });
|
||||
await exec(command, undefined, { silent });
|
||||
|
||||
return tag;
|
||||
}
|
||||
},
|
||||
|
||||
static async run(image, parameters, silent = false) {
|
||||
async run(image, parameters, silent = false) {
|
||||
const { unityVersion, workspace } = parameters;
|
||||
|
||||
const command = `docker run \
|
||||
@@ -50,8 +50,8 @@ class Docker {
|
||||
--volume "${workspace}":"/github/workspace" \
|
||||
${image}`;
|
||||
|
||||
await exec(command, null, { silent });
|
||||
}
|
||||
}
|
||||
await exec(command, undefined, { silent });
|
||||
},
|
||||
};
|
||||
|
||||
export default Docker;
|
||||
@@ -1,41 +0,0 @@
|
||||
import { trimStart } from 'lodash-es';
|
||||
|
||||
class ImageTag {
|
||||
static createForBase(version) {
|
||||
const repository = 'gableroux';
|
||||
const name = 'unity3d';
|
||||
return new this({ repository, name, version });
|
||||
}
|
||||
|
||||
static createForAction(version) {
|
||||
const repository = '';
|
||||
const name = 'unity-action';
|
||||
return new this({ repository, name, version });
|
||||
}
|
||||
|
||||
constructor({ repository = '', name, version }) {
|
||||
if (!ImageTag.versionPattern.test(version)) {
|
||||
throw new Error(`Invalid version "${version}".`);
|
||||
}
|
||||
|
||||
Object.assign(this, { repository, name, version });
|
||||
}
|
||||
|
||||
static get versionPattern() {
|
||||
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
||||
}
|
||||
|
||||
get tag() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
get image() {
|
||||
return trimStart(`${this.repository}/${this.name}`, '/');
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `${this.image}:${this.tag}`;
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageTag;
|
||||
@@ -1,38 +0,0 @@
|
||||
import ImageTag from './image-tag';
|
||||
|
||||
describe('UnityImageVersion', () => {
|
||||
describe('constructor', () => {
|
||||
const some = {
|
||||
name: 'someName',
|
||||
version: '2020.0.00f0',
|
||||
};
|
||||
|
||||
it('can be called', () => {
|
||||
expect(() => new ImageTag(some)).not.toThrow();
|
||||
});
|
||||
|
||||
it('accepts parameters and sets the right properties', () => {
|
||||
const image = new ImageTag(some);
|
||||
|
||||
expect(image.repository).toStrictEqual('');
|
||||
expect(image.name).toStrictEqual(some.name);
|
||||
expect(image.version).toStrictEqual(some.version);
|
||||
});
|
||||
|
||||
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', version => {
|
||||
expect(() => new ImageTag({ version })).not.toThrow();
|
||||
});
|
||||
|
||||
test.each(['some version', '', 1, null])('throws for incorrect versions %p', version => {
|
||||
expect(() => new ImageTag({ version })).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('toString', () => {
|
||||
it('returns the correct version', () => {
|
||||
const image = ImageTag.createForBase('2099.1.1111');
|
||||
|
||||
expect(image.toString()).toStrictEqual(`gableroux/unity3d:2099.1.1111`);
|
||||
});
|
||||
});
|
||||
});
|
||||
22
src/model/image-tag.test.ts
Normal file
22
src/model/image-tag.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import ImageTag from './image-tag';
|
||||
|
||||
describe('ImageTag', () => {
|
||||
describe('constructor', () => {
|
||||
const unityVersion = '2020.0.00f0';
|
||||
|
||||
it('can be called', () => {
|
||||
expect(() => new ImageTag(unityVersion)).not.toThrow();
|
||||
});
|
||||
|
||||
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => {
|
||||
expect(() => new ImageTag(version)).not.toThrow();
|
||||
});
|
||||
});
|
||||
describe('toString', () => {
|
||||
it('returns the correct version', () => {
|
||||
const image = new ImageTag('2099.1.1111');
|
||||
|
||||
expect(image.toString()).toStrictEqual(`unityci/editor:ubuntu-2099.1.1111-linux-il2cpp-1`);
|
||||
});
|
||||
});
|
||||
});
|
||||
125
src/model/image-tag.ts
Normal file
125
src/model/image-tag.ts
Normal file
@@ -0,0 +1,125 @@
|
||||
import Platform from './platform';
|
||||
|
||||
class ImageTag {
|
||||
public repository: string;
|
||||
public name: string;
|
||||
public version: string;
|
||||
public platform: any;
|
||||
public builderPlatform: string;
|
||||
public customImage: any;
|
||||
|
||||
constructor(unityVersion: string) {
|
||||
if (!ImageTag.versionPattern.test(unityVersion)) {
|
||||
throw new Error(`Invalid version "${unityVersion}".`);
|
||||
}
|
||||
|
||||
const builderPlatform = ImageTag.getTargetPlatformToImageSuffixMap(
|
||||
Platform.types.StandaloneLinux64,
|
||||
unityVersion,
|
||||
);
|
||||
|
||||
this.repository = 'unityci';
|
||||
this.name = 'editor';
|
||||
this.version = unityVersion;
|
||||
this.platform = Platform.types.StandaloneLinux64;
|
||||
this.builderPlatform = builderPlatform;
|
||||
this.customImage = '';
|
||||
}
|
||||
|
||||
static get versionPattern() {
|
||||
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
||||
}
|
||||
|
||||
static get imageSuffixes() {
|
||||
return {
|
||||
generic: '',
|
||||
webgl: 'webgl',
|
||||
mac: 'mac-mono',
|
||||
windows: 'windows-mono',
|
||||
linux: 'base',
|
||||
linuxIl2cpp: 'linux-il2cpp',
|
||||
android: 'android',
|
||||
ios: 'ios',
|
||||
facebook: 'facebook',
|
||||
};
|
||||
}
|
||||
|
||||
static getTargetPlatformToImageSuffixMap(platform, version) {
|
||||
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } =
|
||||
ImageTag.imageSuffixes;
|
||||
|
||||
const [major, minor] = version.split('.').map((digit) => Number(digit));
|
||||
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
||||
switch (platform) {
|
||||
case Platform.types.StandaloneOSX:
|
||||
return mac;
|
||||
case Platform.types.StandaloneWindows:
|
||||
return windows;
|
||||
case Platform.types.StandaloneWindows64:
|
||||
return windows;
|
||||
case Platform.types.StandaloneLinux64: {
|
||||
// Unity versions before 2019.3 do not support il2cpp
|
||||
if (major >= 2020 || (major === 2019 && minor >= 3)) {
|
||||
return linuxIl2cpp;
|
||||
}
|
||||
return linux;
|
||||
}
|
||||
case Platform.types.iOS:
|
||||
return ios;
|
||||
case Platform.types.Android:
|
||||
return android;
|
||||
case Platform.types.WebGL:
|
||||
return webgl;
|
||||
case Platform.types.WSAPlayer:
|
||||
return windows;
|
||||
case Platform.types.PS4:
|
||||
return windows;
|
||||
case Platform.types.XboxOne:
|
||||
return windows;
|
||||
case Platform.types.tvOS:
|
||||
return windows;
|
||||
case Platform.types.Switch:
|
||||
return windows;
|
||||
// Unsupported
|
||||
case Platform.types.Lumin:
|
||||
return windows;
|
||||
case Platform.types.BJM:
|
||||
return windows;
|
||||
case Platform.types.Stadia:
|
||||
return windows;
|
||||
case Platform.types.Facebook:
|
||||
return facebook;
|
||||
case Platform.types.NoTarget:
|
||||
return generic;
|
||||
|
||||
// Test specific
|
||||
case Platform.types.Test:
|
||||
return generic;
|
||||
default:
|
||||
throw new Error(`
|
||||
Platform must be one of the ones described in the documentation.
|
||||
"${platform}" is currently not supported.`);
|
||||
}
|
||||
}
|
||||
|
||||
get tag() {
|
||||
return `ubuntu-${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
|
||||
}
|
||||
|
||||
get image() {
|
||||
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
|
||||
}
|
||||
|
||||
toString() {
|
||||
const { image, tag, customImage } = this;
|
||||
|
||||
if (customImage && customImage !== '') {
|
||||
return customImage;
|
||||
}
|
||||
|
||||
const dockerRepoVersion = 1;
|
||||
return `${image}:${tag}-${dockerRepoVersion}`;
|
||||
}
|
||||
}
|
||||
|
||||
export default ImageTag;
|
||||
@@ -1,6 +0,0 @@
|
||||
import Action from './action';
|
||||
import Docker from './docker';
|
||||
import Input from './input';
|
||||
import ImageTag from './image-tag';
|
||||
|
||||
export { Action, Docker, Input, ImageTag };
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as Index from '.';
|
||||
|
||||
describe('Index', () => {
|
||||
test.each(['Action', 'Docker', 'ImageTag', 'Input'])('exports %s', exportedModule => {
|
||||
expect(typeof Index[exportedModule]).toStrictEqual('function');
|
||||
test.each(['Action', 'Docker', 'ImageTag', 'Input'])('exports %s', (exportedModule) => {
|
||||
expect(Index[exportedModule]).toBeDefined();
|
||||
});
|
||||
});
|
||||
5
src/model/index.ts
Normal file
5
src/model/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export { default as Action } from './action';
|
||||
export { default as Input } from './input';
|
||||
export { default as Docker } from './docker';
|
||||
|
||||
export { default as ImageTag } from './image-tag';
|
||||
@@ -1,15 +0,0 @@
|
||||
const core = require('@actions/core');
|
||||
|
||||
class Input {
|
||||
static getFromUser() {
|
||||
// Input variables specified in workflow using "with" prop.
|
||||
const unityVersion = core.getInput('unityVersion') || '2019.2.11f1';
|
||||
|
||||
// Return sanitised input
|
||||
return {
|
||||
unityVersion,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default Input;
|
||||
@@ -1,13 +0,0 @@
|
||||
import Input from './input';
|
||||
|
||||
describe('Input', () => {
|
||||
describe('getFromUser', () => {
|
||||
it('does not throw', () => {
|
||||
expect(() => Input.getFromUser()).not.toThrow();
|
||||
});
|
||||
|
||||
it('returns an object', () => {
|
||||
expect(typeof Input.getFromUser()).toStrictEqual('object');
|
||||
});
|
||||
});
|
||||
});
|
||||
18
src/model/input.test.ts
Normal file
18
src/model/input.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import Input from './input';
|
||||
|
||||
describe('Input', () => {
|
||||
describe('unityVersion', () => {
|
||||
it('returns the default value', () => {
|
||||
expect(Input.unityVersion).toStrictEqual('2019.2.11f1');
|
||||
});
|
||||
|
||||
it('takes input from the users workflow', () => {
|
||||
const mockValue = '2020.4.99f9';
|
||||
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
|
||||
expect(Input.unityVersion).toStrictEqual(mockValue);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
9
src/model/input.ts
Normal file
9
src/model/input.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
const Input = {
|
||||
get unityVersion() {
|
||||
return core.getInput('unityVersion') || '2019.2.11f1';
|
||||
},
|
||||
};
|
||||
|
||||
export default Input;
|
||||
37
src/model/platform.test.ts
Normal file
37
src/model/platform.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import Platform from './platform';
|
||||
|
||||
describe('Platform', () => {
|
||||
describe('default', () => {
|
||||
it('does not throw', () => {
|
||||
expect(() => Platform.default).not.toThrow();
|
||||
});
|
||||
|
||||
it('returns a string', () => {
|
||||
expect(typeof Platform.default).toStrictEqual('string');
|
||||
});
|
||||
|
||||
it('returns a platform', () => {
|
||||
expect(Object.values(Platform.types)).toContain(Platform.default);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isWindows', () => {
|
||||
it('returns true for windows', () => {
|
||||
expect(Platform.isWindows(Platform.types.StandaloneWindows64)).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('returns false for MacOS', () => {
|
||||
expect(Platform.isWindows(Platform.types.StandaloneOSX)).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isAndroid', () => {
|
||||
it('returns true for Android', () => {
|
||||
expect(Platform.isAndroid(Platform.types.Android)).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('returns false for Windows', () => {
|
||||
expect(Platform.isAndroid(Platform.types.StandaloneWindows64)).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
51
src/model/platform.ts
Normal file
51
src/model/platform.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
const Platform = {
|
||||
get default() {
|
||||
return Platform.types.StandaloneWindows64;
|
||||
},
|
||||
|
||||
get types() {
|
||||
return {
|
||||
StandaloneOSX: 'StandaloneOSX',
|
||||
StandaloneWindows: 'StandaloneWindows',
|
||||
StandaloneWindows64: 'StandaloneWindows64',
|
||||
StandaloneLinux64: 'StandaloneLinux64',
|
||||
iOS: 'iOS',
|
||||
Android: 'Android',
|
||||
WebGL: 'WebGL',
|
||||
WSAPlayer: 'WSAPlayer',
|
||||
PS4: 'PS4',
|
||||
XboxOne: 'XboxOne',
|
||||
tvOS: 'tvOS',
|
||||
Switch: 'Switch',
|
||||
// Unsupported
|
||||
Lumin: 'Lumin',
|
||||
BJM: 'BJM',
|
||||
Stadia: 'Stadia',
|
||||
Facebook: 'Facebook',
|
||||
NoTarget: 'NoTarget',
|
||||
// Test specific
|
||||
Test: 'Test',
|
||||
};
|
||||
},
|
||||
|
||||
isWindows(platform) {
|
||||
switch (platform) {
|
||||
case Platform.types.StandaloneWindows:
|
||||
case Platform.types.StandaloneWindows64:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
isAndroid(platform) {
|
||||
switch (platform) {
|
||||
case Platform.types.Android:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default Platform;
|
||||
12
tsconfig.json
Normal file
12
tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
"noImplicitAny": false /* Re-enable after fixing compatibility */ /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user