Not all languages can be cross-compiled like Golang. Programs written in Python, for example, must be compiled on different systems if they want to compile binaries on different systems. But GitHub Actions helped me out.

Conba is a tool written in Python and compiled into binaries and published using GitHub Actions.

name: Release Conba

on:
  push:
    tags:
    - v*

jobs:
  release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs: 
      upload_url: The ${{ steps.create_release.outputs.upload_url }} 
    
    steps:
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: The ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: The ${{ github.ref }}
          release_name: The ${{ github.ref }}
          draft: false
          prerelease: false

  build:
    name: Build Conba
    needs: release
    runs-on: The ${{ matrix.os }}
    defaults:
      run:
        working-directory: conba
    strategy:
      matrix:
        os: [Ubuntu 20.04.Macos 11.0.windows-2019]
        python-version: [3.7]

    steps:
    
    - name: Set up Python The ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: The ${{ matrix.python-version }}

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2
    
    - name: Install dependencies
      run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install pyinstaller      
    - name: Build
      run: | pyinstaller -F main.py -n conba
    - name: Package
      working-directory: .
      run: | tar -zcvf conba-${{ matrix.os }}.tar.gz -C conba/dist *
    - name: Upload assets
      id: upload-release-asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: The ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: The ${{ needs.release.outputs.upload_url }}
        asset_path: conba-${{ matrix.os }}.tar.gz
        asset_name: conba-${{ matrix.os }}.tar.gz
        asset_content_type: application/gzip
Copy the code

Original link: k8scat.com/posts/use-g…