mirror of
https://github.com/game-ci/unity-activate
synced 2026-01-29 06:20:06 +08:00
Compare commits
78 Commits
v1.1
...
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 | ||
|
|
cda570d759 | ||
|
|
c900435e8d | ||
|
|
d36e32af8f | ||
|
|
980dad6633 | ||
|
|
78c5490559 | ||
|
|
1b2ac53764 | ||
|
|
277a3893da | ||
|
|
4220a3cd13 | ||
|
|
81eda991fb | ||
|
|
69d3196ac8 | ||
|
|
53f04dcbb4 | ||
|
|
258d979ec2 | ||
|
|
ae2fe47d82 | ||
|
|
b94fe43f90 | ||
|
|
bf73097b20 | ||
|
|
cc162eef5b | ||
|
|
4593ea898b | ||
|
|
ad9d3edbbb | ||
|
|
eb49eaa7f0 | ||
|
|
098159bbc4 | ||
|
|
d4398e34c1 | ||
|
|
3ffb6cdbd6 | ||
|
|
fadb5b7160 | ||
|
|
7f14e08906 | ||
|
|
5467728a66 | ||
|
|
4d76f5d027 | ||
|
|
56ffb86bcf | ||
|
|
2fe11c3ac3 | ||
|
|
a192cd3d49 | ||
|
|
d8e308b0f5 | ||
|
|
864f769c97 | ||
|
|
4b4f6a58c2 | ||
|
|
0ac0b223a1 | ||
|
|
b3500d9d1e | ||
|
|
5946d10d45 | ||
|
|
5614de49b6 | ||
|
|
be7a9e28a2 | ||
|
|
afb3a70bdf | ||
|
|
8c3e02a6c8 | ||
|
|
84cb112b7e | ||
|
|
2a04635f7a | ||
|
|
cd76fed14c | ||
|
|
271ac6eac9 | ||
|
|
d786d61c77 | ||
|
|
02967cea9e | ||
|
|
8269c18142 | ||
|
|
29197ce88c | ||
|
|
6854c930fe |
@@ -2,5 +2,4 @@
|
||||
*
|
||||
|
||||
# Files required for the action
|
||||
!entrypoint.sh
|
||||
!action.yml
|
||||
!dist/
|
||||
|
||||
@@ -11,11 +11,11 @@ tab_width = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = 0
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
max_line_length = 0
|
||||
[*.{yml,yaml}]
|
||||
max_line_length = off
|
||||
|
||||
[COMMIT_EDITMSG]
|
||||
max_line_length = 0
|
||||
max_line_length = off
|
||||
|
||||
4
.eslintignore
Normal file
4
.eslintignore
Normal file
@@ -0,0 +1,4 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
jest.config.js
|
||||
22
.eslintrc.json
Normal file
22
.eslintrc.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"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/globals": true
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"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)
|
||||
33
.github/workflows/main.yml
vendored
33
.github/workflows/main.yml
vendored
@@ -1,20 +1,45 @@
|
||||
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>"
|
||||
|
||||
jobs:
|
||||
requestActivation:
|
||||
name: Request activation ✔
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- 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 dist || { echo "dist should be auto generated" ; exit 62; }
|
||||
|
||||
requestActivation:
|
||||
name: Activate ${{ matrix.unityVersion }} ✔
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
unityVersion:
|
||||
# Note: Major version differences may require different activation files.
|
||||
- 2018.4.15f1
|
||||
- 2019.2.11f1
|
||||
- 2019.2.14f1
|
||||
- 2019.2.17f1
|
||||
steps:
|
||||
# Checkout repository (required to test local actions)
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Activate Unity
|
||||
- name: Activate Unity
|
||||
uses: ./
|
||||
with:
|
||||
unityVersion: ${{ matrix.unityVersion }}
|
||||
|
||||
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
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +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
|
||||
2
.prettierignore
Normal file
2
.prettierignore
Normal file
@@ -0,0 +1,2 @@
|
||||
**/node_modules/**
|
||||
**/dist/**
|
||||
6
.prettierrc.json
Normal file
6
.prettierrc.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 100
|
||||
}
|
||||
3
.yarnrc
Normal file
3
.yarnrc
Normal file
@@ -0,0 +1,3 @@
|
||||
save-prefix "^"
|
||||
--install.audit true
|
||||
--add.audit true
|
||||
@@ -19,8 +19,20 @@ When fixing a bug it is fine to submit a pull request right away.
|
||||
|
||||
Steps to be performed to submit a pull request:
|
||||
|
||||
1. Fork the repository and create your branch from `master`
|
||||
2. Fill out the description, link any related issues and submit your pull request.
|
||||
1. Fork the repository and create your branch from `master`.
|
||||
2. Run `yarn` in the repository root.
|
||||
3. If you've fixed a bug or added code that should be tested, add tests!
|
||||
4. Fill out the description, link any related issues and submit your pull request.
|
||||
|
||||
#### Pull Request Prerequisites
|
||||
|
||||
You have [Node](https://nodejs.org/) installed at v12.2.0+ and [Yarn](https://yarnpkg.com/) at v1.18.0+.
|
||||
|
||||
Please note that commit hooks will run automatically to perform some tasks;
|
||||
|
||||
- format your code
|
||||
- run tests
|
||||
- build distributable files
|
||||
|
||||
#### License
|
||||
|
||||
|
||||
92
README.md
92
README.md
@@ -1,82 +1,50 @@
|
||||
# Unity - Activate
|
||||
[](https://github.com/webbertakken/unity-activate/actions?query=branch%3Amaster+workflow%3A"Actions+😎")
|
||||
|
||||
---
|
||||
(Not affiliated with Unity Technologies)
|
||||
|
||||
GitHub Action to [activate Unity](https://github.com/marketplace/actions/unity-activate).
|
||||
GitHub Action to [activate](https://github.com/marketplace/actions/unity-activate) Unity.
|
||||
|
||||
Part of the [Unity Actions](https://github.com/webbertakken/unity-actions) collection.
|
||||
Part of the <a href="https://game.ci">GameCI</a> open source project.
|
||||
<br />
|
||||
<br />
|
||||
|
||||
---
|
||||
[](https://github.com/game-ci/unity-activate/actions/workflows/main.yml)
|
||||
<br />
|
||||
<br />
|
||||
|
||||
Use this action to activate Unity using credentials or a license file. Both
|
||||
**personal** and **professional** licenses are supported.
|
||||
## How to use
|
||||
|
||||
When successfully activated, you will be able to run the
|
||||
[Test](https://github.com/webbertakken/unity-actions#test) and
|
||||
[Build](https://github.com/webbertakken/unity-actions#build)
|
||||
actions.
|
||||
Find the
|
||||
[docs](https://game.ci/docs/github/activation)
|
||||
on the GameCI
|
||||
[documentation website](https://game.ci/docs).
|
||||
|
||||
### Documentation
|
||||
## Related actions
|
||||
|
||||
See the
|
||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||
collection repository for workflow documentation and reference implementation.
|
||||
Visit the
|
||||
GameCI <a href="https://github.com/game-ci/unity-actions">Unity Actions</a>
|
||||
status repository for related Actions.
|
||||
|
||||
## Usage
|
||||
## Community
|
||||
|
||||
Create or edit the file called `.github/workflows/activation.yml` and add a job to it.
|
||||
|
||||
```yaml
|
||||
name: Activate Unity
|
||||
on: [push]
|
||||
jobs:
|
||||
requestActivation:
|
||||
name: Request activation ✔
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
```
|
||||
Feel free to join us on
|
||||
<a href="http://game.ci/discord"><img height="30" src="media/Discord-Logo.svg" alt="Discord" /></a>
|
||||
and engage with the community.
|
||||
|
||||
Continue to either the personal license or professional license section below.
|
||||
## Contributing
|
||||
|
||||
#### Personal license
|
||||
To help improve the documentation, please find the docs [repository](https://github.com/game-ci/documentation).
|
||||
|
||||
1. Follow the **activation** section from [request action](https://github.com/marketplace/actions/unity-request-activation-file) to set `UNITY_LICENSE` variable.
|
||||
2. Use the action as follows:
|
||||
To contribute to this project, kindly read the [contribution guide](./CONTRIBUTING.md).
|
||||
|
||||
```yaml
|
||||
- name: Activate Unity
|
||||
uses: webbertakken/unity-activate@v1.1
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
```
|
||||
## Support us
|
||||
|
||||
#### Professional license
|
||||
GameCI is free for everyone forever.
|
||||
|
||||
1. Goto `Repository` > `Settings` > `Secrets`
|
||||
2. Set the following secrets:
|
||||
- `UNITY_EMAIL`: <your_unity_login_email_address>
|
||||
- `UNITY_PASSWORD`: <your_unity_login_password>
|
||||
- `UNITY_SERIAL`: <your_unity_serial>
|
||||
3. Use the action as follows:
|
||||
You can support us at [OpenCollective](https://opencollective.com/game-ci).
|
||||
|
||||
```yaml
|
||||
- name: Activate Unity
|
||||
uses: webbertakken/unity-activate@v1.1
|
||||
env:
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||
```
|
||||
## Licence
|
||||
|
||||
## More actions
|
||||
This repository is [MIT](./LICENSE) licensed.
|
||||
|
||||
Visit
|
||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||
to find related actions for Unity.
|
||||
|
||||
Feel free to contribute.
|
||||
|
||||
## Licence
|
||||
|
||||
[MIT](./LICENSE)
|
||||
This includes all contributions from the community.
|
||||
|
||||
12
action.yml
12
action.yml
@@ -1,11 +1,15 @@
|
||||
name: 'Unity - Activate'
|
||||
author: Webber Takken <webber@takken.io>
|
||||
description: 'Activate Unity using credentials or a license file. Both personal and professional licenses are supported.'
|
||||
inputs: {}
|
||||
inputs:
|
||||
unityVersion:
|
||||
required: false
|
||||
default: '2019.2.11f1'
|
||||
description: 'Version of unity to use for building the project.'
|
||||
outputs: {}
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
branding:
|
||||
icon: 'box'
|
||||
color: 'gray-dark'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
3
Dockerfile → dist/Dockerfile
vendored
3
Dockerfile → dist/Dockerfile
vendored
@@ -1,4 +1,5 @@
|
||||
FROM gableroux/unity3d:2019.2.11f1
|
||||
ARG IMAGE
|
||||
FROM $IMAGE
|
||||
|
||||
LABEL "com.github.actions.name"="Unity - Activate"
|
||||
LABEL "com.github.actions.description"="Activate Unity using credentials or a license file. Both personal and professional licenses are supported."
|
||||
56
entrypoint.sh → dist/entrypoint.sh
vendored
56
entrypoint.sh → dist/entrypoint.sh
vendored
@@ -1,6 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -n "$UNITY_LICENSE" ]]; then
|
||||
#
|
||||
# Create directory for license activation
|
||||
#
|
||||
ACTIVATE_LICENSE_PATH="$GITHUB_WORKSPACE/_activate-license"
|
||||
mkdir -p "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
# Run in ACTIVATE_LICENSE_PATH directory
|
||||
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
|
||||
pushd "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||
#
|
||||
# PERSONAL LICENSE MODE
|
||||
#
|
||||
@@ -15,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)
|
||||
@@ -58,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=$?
|
||||
@@ -79,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.
|
||||
@@ -95,7 +104,18 @@ if [ $UNITY_EXIT_CODE -eq 0 ]; then
|
||||
echo "Activation complete."
|
||||
else
|
||||
# Activation failed so exit with the code from the license verification step
|
||||
echo "Unclassified error occured while trying to activate license."
|
||||
echo "###########################"
|
||||
echo "# Failure #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
echo "Please note that the exit code is not very descriptive."
|
||||
echo "Most likely it will not help you solve the issue."
|
||||
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
11
jest.config.js
Normal file
11
jest.config.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
verbose: true,
|
||||
};
|
||||
1
media/Discord-Logo.svg
Normal file
1
media/Discord-Logo.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 272.1"><style>.st0{fill:#7289DA;}</style><path class="st0" d="M142.8 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11s-4.6-11-10.2-11zM106.3 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11 .1-6.1-4.5-11-10.2-11z"/><path class="st0" d="M191.4 36.9h-134c-11.3 0-20.5 9.2-20.5 20.5v134c0 11.3 9.2 20.5 20.5 20.5h113.4l-5.3-18.3 12.8 11.8 12.1 11.1 21.6 18.7V57.4c-.1-11.3-9.3-20.5-20.6-20.5zm-38.6 129.5s-3.6-4.3-6.6-8c13.1-3.7 18.1-11.8 18.1-11.8-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.4-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.6-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.2-1.8-1-2.8-1.7-2.8-1.7s4.8 7.9 17.5 11.7c-3 3.8-6.7 8.2-6.7 8.2-22.1-.7-30.5-15.1-30.5-15.1 0-31.9 14.4-57.8 14.4-57.8 14.4-10.7 28-10.4 28-10.4l1 1.2c-18 5.1-26.2 13-26.2 13s2.2-1.2 5.9-2.8c10.7-4.7 19.2-5.9 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.5 0 0-7.9-7.5-24.9-12.6l1.4-1.6s13.7-.3 28 10.4c0 0 14.4 25.9 14.4 57.8 0-.1-8.4 14.3-30.5 15zM303.8 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1h33.2c17.8.1 34.5-8.8 34.5-29.2v-29.8c.1-20.8-16.6-29.9-34.4-29.9zm174 59.7v-30.6c0-11 19.8-13.5 25.8-2.5l18.3-7.4c-7.2-15.8-20.3-20.4-31.2-20.4-17.8 0-35.4 10.3-35.4 30.3v30.6c0 20.2 17.6 30.3 35 30.3 11.2 0 24.6-5.5 32-19.9l-19.6-9c-4.8 12.3-24.9 9.3-24.9-1.4zM417.3 113c-6.9-1.5-11.5-4-11.8-8.3.4-10.3 16.3-10.7 25.6-.8l14.7-11.3c-9.2-11.2-19.6-14.2-30.3-14.2-16.3 0-32.1 9.2-32.1 26.6 0 16.9 13 26 27.3 28.2 7.3 1 15.4 3.9 15.2 8.9-.6 9.5-20.2 9-29.1-1.8l-14.2 13.3c8.3 10.7 19.6 16.1 30.2 16.1 16.3 0 34.4-9.4 35.1-26.6 1-21.7-14.8-27.2-30.6-30.1zm-67 55.5h22.4V79.7h-22.4v88.8zM728 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1H728c17.8.1 34.5-8.8 34.5-29.2v-29.8c0-20.8-16.7-29.9-34.5-29.9zm-162.9-1.2c-18.4 0-36.7 10-36.7 30.5v30.3c0 20.3 18.4 30.5 36.9 30.5 18.4 0 36.7-10.2 36.7-30.5V109c0-20.4-18.5-30.5-36.9-30.5zm14.4 60.8c0 6.4-7.2 9.7-14.3 9.7-7.2 0-14.4-3.1-14.4-9.7V109c0-6.5 7-10 14-10 7.3 0 14.7 3.1 14.7 10v30.3zM682.4 109c-.5-20.8-14.7-29.2-33-29.2h-35.5v88.8h22.7v-28.2h4l20.6 28.2h28L665 138.1c10.7-3.4 17.4-12.7 17.4-29.1zm-32.6 12h-13.2v-20.3h13.2c14.1 0 14.1 20.3 0 20.3z"/></svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
53
package.json
Normal file
53
package.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "unity-activate",
|
||||
"version": "2.0.0",
|
||||
"description": "Activate Unity using credentials or a license file. Both personal and professional licenses are supported.",
|
||||
"main": "dist/index.js",
|
||||
"repository": "git@github.com:game-ci/unity-activate.git",
|
||||
"author": "Webber <webber@takken.io>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"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.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/github": "^2.2.0",
|
||||
"@octokit/core": "^6.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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,ts,tsx}": [
|
||||
"prettier --write",
|
||||
"eslint",
|
||||
"jest --findRelatedTests"
|
||||
],
|
||||
"*.{json,md,yaml,yml}": [
|
||||
"prettier --write"
|
||||
]
|
||||
}
|
||||
}
|
||||
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();
|
||||
36
src/model/action.test.ts
Normal file
36
src/model/action.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import Action from './action';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
describe('Action', () => {
|
||||
describe('compatibility check', () => {
|
||||
it('throws for anything other than linux', () => {
|
||||
if (process.platform !== 'linux') {
|
||||
expect(() => Action.checkCompatibility()).toThrow();
|
||||
} else {
|
||||
expect(() => Action.checkCompatibility()).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the root folder of the action', () => {
|
||||
const { rootFolder, canonicalName } = Action;
|
||||
|
||||
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('dist');
|
||||
expect(fs.existsSync(actionFolder)).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it('returns the docker file', () => {
|
||||
const { dockerfile } = Action;
|
||||
|
||||
expect(path.basename(dockerfile)).toStrictEqual('Dockerfile');
|
||||
expect(fs.existsSync(dockerfile)).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
48
src/model/action.ts
Normal file
48
src/model/action.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import path from 'path';
|
||||
|
||||
const Action = {
|
||||
get supportedPlatforms() {
|
||||
return ['linux'];
|
||||
},
|
||||
|
||||
get isRunningLocally() {
|
||||
return process.env.RUNNER_WORKSPACE === undefined;
|
||||
},
|
||||
|
||||
get isRunningFromSource() {
|
||||
return path.basename(__dirname) === 'model';
|
||||
},
|
||||
|
||||
get canonicalName() {
|
||||
return 'unity-activate';
|
||||
},
|
||||
|
||||
get rootFolder() {
|
||||
if (Action.isRunningFromSource) {
|
||||
return path.dirname(path.dirname(path.dirname(__filename)));
|
||||
}
|
||||
|
||||
return path.dirname(path.dirname(__filename));
|
||||
},
|
||||
|
||||
get actionFolder() {
|
||||
return `${Action.rootFolder}/dist`;
|
||||
},
|
||||
|
||||
get dockerfile() {
|
||||
return `${Action.actionFolder}/Dockerfile`;
|
||||
},
|
||||
|
||||
get workspace() {
|
||||
return process.env.GITHUB_WORKSPACE;
|
||||
},
|
||||
|
||||
checkCompatibility() {
|
||||
const currentPlatform = process.platform;
|
||||
if (!Action.supportedPlatforms.includes(currentPlatform)) {
|
||||
throw new Error(`Currently ${currentPlatform}-platform is not supported`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default Action;
|
||||
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);
|
||||
});
|
||||
});
|
||||
57
src/model/docker.ts
Normal file
57
src/model/docker.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import ImageTag from './image-tag';
|
||||
import { exec } from '@actions/exec';
|
||||
|
||||
const Docker = {
|
||||
async build(buildParameters, silent = false) {
|
||||
const { path, dockerfile, baseImage } = buildParameters;
|
||||
const { version } = baseImage;
|
||||
|
||||
const tag = new ImageTag(version);
|
||||
const command = `docker build ${path} \
|
||||
--file ${dockerfile} \
|
||||
--build-arg IMAGE=${baseImage} \
|
||||
--tag ${tag}`;
|
||||
|
||||
await exec(command, undefined, { silent });
|
||||
|
||||
return tag;
|
||||
},
|
||||
|
||||
async run(image, parameters, silent = false) {
|
||||
const { unityVersion, workspace } = parameters;
|
||||
|
||||
const command = `docker run \
|
||||
--workdir /github/workspace \
|
||||
--rm \
|
||||
--env UNITY_LICENSE \
|
||||
--env UNITY_EMAIL \
|
||||
--env UNITY_PASSWORD \
|
||||
--env UNITY_SERIAL \
|
||||
--env UNITY_VERSION=${unityVersion} \
|
||||
--env HOME=/github/home \
|
||||
--env GITHUB_REF \
|
||||
--env GITHUB_SHA \
|
||||
--env GITHUB_REPOSITORY \
|
||||
--env GITHUB_ACTOR \
|
||||
--env GITHUB_WORKFLOW \
|
||||
--env GITHUB_HEAD_REF \
|
||||
--env GITHUB_BASE_REF \
|
||||
--env GITHUB_EVENT_NAME \
|
||||
--env GITHUB_WORKSPACE=/github/workspace \
|
||||
--env GITHUB_ACTION \
|
||||
--env GITHUB_EVENT_PATH \
|
||||
--env RUNNER_OS \
|
||||
--env RUNNER_TOOL_CACHE \
|
||||
--env RUNNER_TEMP \
|
||||
--env RUNNER_WORKSPACE \
|
||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
||||
--volume "/home/runner/work/_temp/_github_home":"/github/home" \
|
||||
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
|
||||
--volume "${workspace}":"/github/workspace" \
|
||||
${image}`;
|
||||
|
||||
await exec(command, undefined, { silent });
|
||||
},
|
||||
};
|
||||
|
||||
export default Docker;
|
||||
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;
|
||||
7
src/model/index.test.ts
Normal file
7
src/model/index.test.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as Index from '.';
|
||||
|
||||
describe('Index', () => {
|
||||
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';
|
||||
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