- 
                Notifications
    You must be signed in to change notification settings 
- Fork 55
CM-22808 - Build CLI executable #112
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 18 commits
      Commits
    
    
            Show all changes
          
          
            26 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      7f01736
              
                Add Pyinstaller and spec for it; remove legacy and unused dep
              
              
                MarshalX 0dbc78e
              
                add ability to get the version at the process of bundle creation
              
              
                MarshalX 82f8854
              
                Build executable version of CLI for Linux
              
              
                MarshalX 4cd6f88
              
                upload executable as artifacts
              
              
                MarshalX 1a4da58
              
                add macos
              
              
                MarshalX 86b076d
              
                update path
              
              
                MarshalX fb565f3
              
                add windows
              
              
                MarshalX c625fd9
              
                fix win test
              
              
                MarshalX 3a322fb
              
                fix win test 2
              
              
                MarshalX c75b91b
              
                update win path
              
              
                MarshalX 804196f
              
                update win path 2
              
              
                MarshalX d88065a
              
                update win path 3
              
              
                MarshalX 21160ac
              
                run on all runners
              
              
                MarshalX 71788f3
              
                fix startsWith
              
              
                MarshalX 421d88e
              
                fix startsWith 2
              
              
                MarshalX c5afe75
              
                attempt to build universal binary for macos
              
              
                MarshalX 7c39e82
              
                bump python version to 3.11
              
              
                MarshalX 954a318
              
                rework installation of Poetry
              
              
                MarshalX 671fca9
              
                trigger
              
              
                MarshalX 131de4e
              
                rollback python to 3.7; disable fast fail
              
              
                MarshalX f57ebcc
              
                build macos binary for the same arch as the current one
              
              
                MarshalX 868306a
              
                use bash for all OS
              
              
                MarshalX 7c6f0ed
              
                attempt to use lower OS version as possible
              
              
                MarshalX af391e0
              
                Merge branch 'main' into CM-22808-Build-CLI-executable
              
              
                MarshalX b7e872a
              
                don't depend on Git for resolve CLI version in bundles anymore
              
              
                MarshalX 4d357a9
              
                trigger on main branch only
              
              
                MarshalX File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: Build executable version of CLI | ||
|  | ||
| on: | ||
| push: | ||
| branches: | ||
| # - main | ||
| - "CM-22808-Build-CLI-executable" | ||
|  | ||
| jobs: | ||
| build: | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
|  | ||
| runs-on: ${{ matrix.os }} | ||
|  | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
|  | ||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
|  | ||
| - name: Setup Poetry | ||
| uses: snok/install-poetry@v1 | ||
|         
                  MarshalX marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| - name: Install dependencies | ||
| run: poetry install | ||
|  | ||
| - name: Build executable | ||
| run: poetry run pyinstaller pyinstaller.spec | ||
|  | ||
| - name: Test executable | ||
| if: ${{ !startsWith(matrix.os, 'windows') }} | ||
| run: ./dist/cycode --version | ||
|  | ||
| - name: Test executable on Windows | ||
| if: ${{ startsWith(matrix.os, 'windows') }} | ||
| run: Invoke-expression -command ".\dist\cycode.exe --version" | ||
|  | ||
| - uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: cycode-cli-${{ matrix.os }} | ||
| path: dist | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = '0.0.0' # placeholder. Will be filled automatically on poetry build from Git Tag | ||
| __version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag | 
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # -*- mode: python ; coding: utf-8 -*- | ||
| # Run `poetry run pyinstaller pyinstaller.spec` to generate the binary. | ||
|  | ||
|  | ||
| block_cipher = None | ||
|  | ||
| INIT_FILE_PATH = os.path.join('cycode', '__init__.py') | ||
|  | ||
| # save the prev content of __init__ file | ||
| with open(INIT_FILE_PATH, 'r', encoding='UTF-8') as file: | ||
| prev_content = file.read() | ||
|  | ||
| new_content = """ | ||
| import dunamai as _dunamai | ||
| __version__ = _dunamai.get_version('cycode', first_choice=_dunamai.Version.from_git).serialize( | ||
| metadata=False, bump=True, style=_dunamai.Style.Pep440 | ||
| ) | ||
| """ | ||
|  | ||
| # write the code to get version from Git Tag in runtime | ||
| # the code will be compiled once during creation of the bundle | ||
| # the value of __version__ will be frozen | ||
| with open(INIT_FILE_PATH, 'w', encoding='UTF-8') as file: | ||
| file.write(new_content) | ||
|  | ||
| a = Analysis( | ||
| ['cycode/cli/main.py'], | ||
| pathex=[], | ||
| binaries=[], | ||
| datas=[('cycode/cli/config.yaml', 'cycode/cli'), ('cycode/cyclient/config.yaml', 'cycode/cyclient')], | ||
| hiddenimports=[], | ||
| hookspath=[], | ||
| hooksconfig={}, | ||
| runtime_hooks=[], | ||
| excludes=['tests'], | ||
| win_no_prefer_redirects=False, | ||
| win_private_assemblies=False, | ||
| cipher=block_cipher, | ||
| noarchive=False, | ||
| ) | ||
| pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) | ||
|  | ||
| exe = EXE( | ||
| pyz, | ||
| a.scripts, | ||
| a.binaries, | ||
| a.zipfiles, | ||
| a.datas, | ||
| [], | ||
| name='cycode', | ||
| debug=False, | ||
| bootloader_ignore_signals=False, | ||
| strip=False, | ||
| upx=True, | ||
| upx_exclude=[], | ||
| runtime_tmpdir=None, | ||
| console=True, | ||
| disable_windowed_traceback=False, | ||
| argv_emulation=False, | ||
| target_arch='universal2', | ||
| codesign_identity=None, | ||
| entitlements_file=None, | ||
| ) | ||
|  | ||
| # rollback the prev content of the __init__ file | ||
| with open(INIT_FILE_PATH, 'w', encoding='UTF-8') as file: | ||
| file.write(prev_content) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.