Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RELATIVE_PROJECT_PATH in export #28

Merged
merged 17 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Since this action creates releases and uploads the zip file assets, you will nee
- If release notes should be automatically generated based on commit history. The generated notes will be added as the body of the release.
- **Note**: This input is only used when `create_release` is `true`.
- **Note**: When using the GitHub checkout action, ensure you are fetching the entire project history by including `fetch-depth: 0`. See the example workflow configuration for more context.
- `use_preset_export_path` default `false`
- If set to true, exports will be moved to directory defined in `export_presets.cfg` relative to the root of the Git repository. Prioritized over `relative_export_path`.
- `relative_export_path` default `''`
- If provided, exports will be moved to this directory relative to the root of the Git repository.
- `update_windows_icons` default `false`
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ inputs:
description: If release notes should be automatically generated based on commit history.
default: false
required: false
use_preset_export_path:
description: If set to true, exports will be moved to directory defined in "export_presets.cfg" relative to the root of the Git repository. Prioritized over "relative_export_path".
default: false
required: false
relative_export_path:
description: If provided, exports will be moved to this directory relative to the root of the Git repository.
default: ''
Expand Down
9 changes: 5 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11921,6 +11921,7 @@ const RELATIVE_EXPORT_PATH = Object(core.getInput)('relative_export_path');
const RELATIVE_PROJECT_PATH = Object(core.getInput)('relative_project_path');
const SHOULD_CREATE_RELEASE = Object(core.getInput)('create_release') === 'true';
const UPDATE_WINDOWS_ICONS = Object(core.getInput)('update_windows_icons') === 'true';
const USE_PRESET_EXPORT_PATH = Object(core.getInput)('use_preset_export_path') === 'true';
const GODOT_WORKING_PATH = external_path_default().resolve(external_path_default().join(Object(external_os_.homedir)(), '/.local/share/godot'));
const GODOT_CONFIG_PATH = external_path_default().resolve(external_path_default().join(Object(external_os_.homedir)(), '/.config/godot'));

Expand Down Expand Up @@ -12247,11 +12248,11 @@ function zipBuildResult(buildResult) {
}
function moveBuildsToExportDirectory(buildResults, moveArchived) {
return file_awaiter(this, void 0, void 0, function* () {
const fullExportPath = external_path_default().resolve(RELATIVE_EXPORT_PATH);
Object(core.startGroup)(`Moving exports to ${fullExportPath}`);
yield Object(io.mkdirP)(fullExportPath);
Object(core.startGroup)(`Moving exports`);
const promises = [];
for (const buildResult of buildResults) {
const fullExportPath = external_path_default().resolve(USE_PRESET_EXPORT_PATH ? external_path_default().dirname(buildResult.preset.export_path) : RELATIVE_EXPORT_PATH);
yield Object(io.mkdirP)(fullExportPath);
let promise;
if (moveArchived) {
if (!buildResult.archivePath) {
Expand Down Expand Up @@ -12455,7 +12456,7 @@ function main() {
if (ARCHIVE_EXPORT_OUTPUT) {
yield zipBuildResults(buildResults);
}
if (RELATIVE_EXPORT_PATH) {
if (RELATIVE_EXPORT_PATH || USE_PRESET_EXPORT_PATH) {
yield moveBuildsToExportDirectory(buildResults, ARCHIVE_EXPORT_OUTPUT);
}
if (SHOULD_CREATE_RELEASE) {
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const RELATIVE_EXPORT_PATH = core.getInput('relative_export_path');
const RELATIVE_PROJECT_PATH = core.getInput('relative_project_path');
const SHOULD_CREATE_RELEASE = core.getInput('create_release') === 'true';
const UPDATE_WINDOWS_ICONS = core.getInput('update_windows_icons') === 'true';
const USE_PRESET_EXPORT_PATH = core.getInput('use_preset_export_path') === 'true';

const GODOT_WORKING_PATH = path.resolve(path.join(os.homedir(), '/.local/share/godot'));
const GODOT_CONFIG_PATH = path.resolve(path.join(os.homedir(), '/.config/godot'));
Expand All @@ -29,4 +30,5 @@ export {
RELATIVE_PROJECT_PATH,
SHOULD_CREATE_RELEASE,
UPDATE_WINDOWS_ICONS,
USE_PRESET_EXPORT_PATH,
};
14 changes: 8 additions & 6 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import * as io from '@actions/io';
import { exec } from '@actions/exec';
import * as fs from 'fs';
import { GODOT_WORKING_PATH, RELATIVE_EXPORT_PATH } from './constants';
import { GODOT_WORKING_PATH, RELATIVE_EXPORT_PATH, USE_PRESET_EXPORT_PATH } from './constants';
import * as core from '@actions/core';

async function zipBuildResults(buildResults: BuildResult[]): Promise<void> {
Expand Down Expand Up @@ -35,13 +35,15 @@ async function zipBuildResult(buildResult: BuildResult): Promise<void> {
}

async function moveBuildsToExportDirectory(buildResults: BuildResult[], moveArchived?: boolean): Promise<void> {
const fullExportPath = path.resolve(RELATIVE_EXPORT_PATH);
core.startGroup(`Moving exports to ${fullExportPath}`);

await io.mkdirP(fullExportPath);

core.startGroup(`Moving exports`);
const promises: Promise<void>[] = [];
for (const buildResult of buildResults) {
const fullExportPath = path.resolve(
USE_PRESET_EXPORT_PATH ? path.dirname(buildResult.preset.export_path) : RELATIVE_EXPORT_PATH,
);

await io.mkdirP(fullExportPath);

let promise: Promise<void>;
if (moveArchived) {
if (!buildResult.archivePath) {
Expand Down
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as core from '@actions/core';
import { exportBuilds } from './godot';
import { createRelease } from './release';
import { SHOULD_CREATE_RELEASE, ARCHIVE_EXPORT_OUTPUT, RELATIVE_EXPORT_PATH } from './constants';
import {
SHOULD_CREATE_RELEASE,
ARCHIVE_EXPORT_OUTPUT,
RELATIVE_EXPORT_PATH,
USE_PRESET_EXPORT_PATH,
} from './constants';
import { zipBuildResults, moveBuildsToExportDirectory } from './file';

async function main(): Promise<number> {
Expand All @@ -15,7 +20,7 @@ async function main(): Promise<number> {
await zipBuildResults(buildResults);
}

if (RELATIVE_EXPORT_PATH) {
if (RELATIVE_EXPORT_PATH || USE_PRESET_EXPORT_PATH) {
await moveBuildsToExportDirectory(buildResults, ARCHIVE_EXPORT_OUTPUT);
}

Expand Down