mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-01-29 20:39:07 +08:00
Compare commits
7 Commits
v2.0-alpha
...
pass-env
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d8fcbb306 | ||
|
|
f79c381dd8 | ||
|
|
ace1903cf7 | ||
|
|
daaf5ccf5f | ||
|
|
a172ba4e62 | ||
|
|
56b9864426 | ||
|
|
5b2e80e1a4 |
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
- run: yarn
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
lfs: true
|
||||
- uses: actions/cache@v1.1.0
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ matrix.projectPath }}/Library
|
||||
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -10,6 +10,11 @@ LABEL "repository"="http://github.com/webbertakken/unity-actions"
|
||||
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
|
||||
LABEL "maintainer"="Webber Takken <webber@takken.io>"
|
||||
|
||||
# To be moved to base image
|
||||
RUN apt-get -q install -y && apt-get clean
|
||||
RUN locale-gen en_US.UTF-8
|
||||
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
|
||||
|
||||
ADD default-build-script /UnityBuilderAction
|
||||
ADD steps /steps
|
||||
RUN chmod -R +x /steps
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -67,10 +67,18 @@ export default class Versioning {
|
||||
/**
|
||||
* Regex to parse version description into separate fields
|
||||
*/
|
||||
static get descriptionRegex() {
|
||||
static get descriptionRegex1() {
|
||||
return /^v([\d.]+)-(\d+)-g(\w+)-?(\w+)*/g;
|
||||
}
|
||||
|
||||
static get descriptionRegex2() {
|
||||
return /^v([\d.]+-\w+)-(\d+)-g(\w+)-?(\w+)*/g;
|
||||
}
|
||||
|
||||
static get descriptionRegex3() {
|
||||
return /^v([\d.]+-\w+\.\d+)-(\d+)-g(\w+)-?(\w+)*/g;
|
||||
}
|
||||
|
||||
static async determineVersion(strategy, inputVersion) {
|
||||
// Validate input
|
||||
if (!Object.hasOwnProperty.call(this.strategies, strategy)) {
|
||||
@@ -125,10 +133,16 @@ export default class Versioning {
|
||||
return version;
|
||||
}
|
||||
|
||||
const { tag, commits, hash } = await this.parseSemanticVersion();
|
||||
core.info(`Found semantic version ${tag}.${commits} for ${this.branch}@${hash}`);
|
||||
const versionDescriptor = await this.parseSemanticVersion();
|
||||
|
||||
return `${tag}.${commits}`;
|
||||
if (versionDescriptor) {
|
||||
const { tag, commits, hash } = versionDescriptor;
|
||||
core.info(`Found semantic version ${tag}.${commits} for ${this.branch}@${hash}`);
|
||||
return `${tag}.${commits}`;
|
||||
}
|
||||
const version = `0.0.${await this.getTotalNumberOfCommits()}`;
|
||||
core.info(`Generated version ${version} (semantic version couldn't be determined).`);
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +165,7 @@ export default class Versioning {
|
||||
const description = await this.getVersionDescription();
|
||||
|
||||
try {
|
||||
const [match, tag, commits, hash] = this.descriptionRegex.exec(description);
|
||||
const [match, tag, commits, hash] = this.descriptionRegex1.exec(description);
|
||||
|
||||
return {
|
||||
match,
|
||||
@@ -160,7 +174,32 @@ export default class Versioning {
|
||||
hash,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to parse git describe output: "${description}".`);
|
||||
try {
|
||||
const [match, tag, commits, hash] = this.descriptionRegex2.exec(description);
|
||||
|
||||
return {
|
||||
match,
|
||||
tag,
|
||||
commits,
|
||||
hash,
|
||||
};
|
||||
} catch (error_) {
|
||||
try {
|
||||
const [match, tag, commits, hash] = this.descriptionRegex3.exec(description);
|
||||
|
||||
return {
|
||||
match,
|
||||
tag,
|
||||
commits,
|
||||
hash,
|
||||
};
|
||||
} catch (error__) {
|
||||
core.warning(
|
||||
`Failed to parse git describe output or version can not be determined through: "${description}".`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,22 +124,22 @@ describe('Versioning', () => {
|
||||
|
||||
describe('descriptionRegex', () => {
|
||||
it('is a valid regex', () => {
|
||||
expect(Versioning.descriptionRegex).toBeInstanceOf(RegExp);
|
||||
expect(Versioning.descriptionRegex1).toBeInstanceOf(RegExp);
|
||||
});
|
||||
|
||||
test.each(['v1.1-1-g12345678', 'v0.1-2-g12345678', 'v0.0-500-gA9B6C3D0-dirty'])(
|
||||
'is happy with valid %s',
|
||||
(description) => {
|
||||
expect(Versioning.descriptionRegex.test(description)).toBeTruthy();
|
||||
expect(Versioning.descriptionRegex1.test(description)).toBeTruthy();
|
||||
},
|
||||
);
|
||||
|
||||
test.each([undefined, 'v0', 'v0.1', 'v0.1.2', 'v0.1-2', 'v0.1-2-g'])(
|
||||
'does not like %s',
|
||||
(description) => {
|
||||
expect(Versioning.descriptionRegex.test(description)).toBeFalsy();
|
||||
expect(Versioning.descriptionRegex1.test(description)).toBeFalsy();
|
||||
// Also never expect without the v to work for any of these cases.
|
||||
expect(Versioning.descriptionRegex.test(description?.substr(1))).toBeFalsy();
|
||||
expect(Versioning.descriptionRegex1.test(description?.substr(1))).toBeFalsy();
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -225,9 +225,7 @@ describe('Versioning', () => {
|
||||
it('throws when no match could be made', async () => {
|
||||
jest.spyOn(Versioning, 'getVersionDescription').mockResolvedValue('no-match-can-be-made');
|
||||
|
||||
await expect(Versioning.parseSemanticVersion()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Failed to parse git describe output: \\"no-match-can-be-made\\"."`,
|
||||
);
|
||||
await expect(Versioning.parseSemanticVersion()).toMatchObject({});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user