Skip to content

Commit

Permalink
Merge pull request #72 from fwcd/refactor-bindist
Browse files Browse the repository at this point in the history
Refactor bindist script to generate gzipped tarballs on Linux and macOS
  • Loading branch information
fwcd authored Jul 29, 2024
2 parents 0abe995 + 7c71b4d commit 1568f09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
shell: bash
run: gh release upload "${{ needs.release.outputs.tag }}" bindists/*
run: gh release upload "${{ needs.release.outputs.tag }}" bindists/*.{tar.gz,zip}
25 changes: 12 additions & 13 deletions scripts/make-bindist
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,31 @@ from pathlib import Path

import argparse
import platform
import shutil
import subprocess
import zipfile

ROOT_DIR = Path(__file__).resolve().parent.parent

def main():
parser = argparse.ArgumentParser(description='Creates a binary distribution of the language server')
parser.add_argument('-o', '--output', type=Path, default=ROOT_DIR / 'bindists' / f'curry-language-server-{platform.machine().lower()}-{platform.system().lower()}.zip', help='The name of the output zip.')
parser.add_argument('-f', '--format', type=str, default='zip' if platform.system() == 'Windows' else 'gztar', help='The format of the output archive.')
parser.add_argument('-o', '--output', type=Path, default=ROOT_DIR / 'bindists' / f'curry-language-server-{platform.machine().lower()}-{platform.system().lower()}', help='The name of the output archive.')

args = parser.parse_args()
bin_dir = 'bin'
output = args.output
format: str = args.format
output: Path = args.output

output.mkdir(parents=True, exist_ok=True)

print('==> Building...')
subprocess.run(['stack', 'install', '--local-bin-path', bin_dir], check=True, cwd=ROOT_DIR)
subprocess.run(['stack', 'install', '--local-bin-path', output / 'bin'], check=True, cwd=ROOT_DIR)

print('==> Packaging...')
shutil.copy('LICENSE', output)

print('==> Archiving...')
output.parent.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(output, mode='w') as zip:
for f in [bin_dir, 'LICENSE']:
path = ROOT_DIR / f
if path.is_dir():
for child in path.rglob('*'):
zip.write(child, child.relative_to(ROOT_DIR))
else:
zip.write(path, path.relative_to(ROOT_DIR))
shutil.make_archive(output, format, output.parent, output.name)

if __name__ == '__main__':
main()

0 comments on commit 1568f09

Please sign in to comment.