Skip to content

Commit

Permalink
simplify workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Jan 8, 2024
1 parent 3f0aa1b commit 09bc110
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build_executable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ jobs:
PROCESS_ONEDIR: ${{ matrix.mode == 'onedir' }}
run: echo "ARTIFACT_NAME=$(./process_executable_file.py dist/cycode-cli)" >> $GITHUB_ENV

- name: Prepare files on Windows
if: runner.os == 'Windows'
env:
PROCESS_ONEDIR: ${{ matrix.mode == 'onedir' }}
run: echo "ARTIFACT_NAME=$(./process_executable_file.py dist/cycode-cli.exe)" >> $GITHUB_ENV

- name: Upload files as artifact
uses: actions/upload-artifact@v3
with:
Expand Down
10 changes: 8 additions & 2 deletions process_executable_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def process_executable_file(input_path: Path, arm: bool, onedir: bool) -> str:
file_hash = get_hash_of_file(input_path)
write_hash_to_file(file_hash, hash_file_path)

if not onedir:
# for example rename cycode-cli to cycode-mac or cycode-mac-arm-onedir
os.rename(input_path, get_cli_path(output_path, arm, onedir))

return get_cli_filename(arm, onedir)
Expand All @@ -144,10 +144,16 @@ def main() -> None:
parser.add_argument('input', help='Path to executable or directory')

args = parser.parse_args()

onedir = args.onedir or parse_bool(os.environ.get('PROCESS_ONEDIR', False))
arm = args.arm or parse_bool(os.environ.get('PROCESS_ARM', False)) or is_arm()

artifact_name = process_executable_file(Path(args.input), arm, onedir)
input_path = Path(args.input)
if get_os_name() == 'windows' and not onedir and input_path.suffix != '.exe':
# add .exe on windows if was missed (to simplify GHA workflow)
input_path = input_path.with_suffix('.exe')

artifact_name = process_executable_file(input_path, arm, onedir)

print(artifact_name) # noqa: T201

Expand Down

0 comments on commit 09bc110

Please sign in to comment.