From ef77649199729892413fea13caaab57257f21a29 Mon Sep 17 00:00:00 2001 From: Hammad Mohiuddin Date: Fri, 8 Mar 2024 11:47:20 -0800 Subject: [PATCH] Added Github workflow to build binary --- .../workflows/build-and-release-binaries.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/build-and-release-binaries.yaml diff --git a/.github/workflows/build-and-release-binaries.yaml b/.github/workflows/build-and-release-binaries.yaml new file mode 100644 index 0000000..233b144 --- /dev/null +++ b/.github/workflows/build-and-release-binaries.yaml @@ -0,0 +1,87 @@ +--- +name: Build and Release Binaries + +on: + release: + types: [published] + tags: + - 'v*' # Push events to matching v*, i.e. v1.0.0, v2.0.0, ... + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + architecture: [x64] + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} + cache: 'pip' + + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + + - name: Install dependencies + run: | + python3 -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip pyinstaller + pip install . + + - name: Build binary + run: | + source venv/bin/activate + pyinstaller --onefile ./venv/bin/tt-flash \ + --add-data tt_flash/data/wormhole/fw_defines.yaml:tt_flash/data/wormhole/ \ + --add-data tt_flash/data/grayskull/fw_defines.yaml:tt_flash/data/grayskull/ + + - name: Rename binary + run: | + mv dist/* "dist/tt_flash-${GITHUB_REF#refs/tags/v}" + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: tt_flash-${GITHUB_REF#refs/tags/v} + path: | + ./dist/* + + # release: + # needs: build + # runs-on: ubuntu-latest + # steps: + # - name: Download Artifacts + # uses: actions/download-artifact@v3 + # with: + # path: artifacts/ + + # - name: Move Wheel Files + # run: | + # mkdir -p wheels + # find artifacts -name '*.whl' -exec mv {} wheels/ \; + + # - name: Upload Wheel Files + # run: | + # cd wheels + # ls -la + # for wheel in *.whl; do + # if [ -f "$wheel" ]; then + # echo "Uploading $wheel" + # curl -L \ + # -X POST \ + # -H "Accept: application/vnd.github+json" \ + # -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + # -H "X-GitHub-Api-Version: 2022-11-28" \ + # -H "Content-Type: application/octet-stream" \ + # "${{ github.event.release.upload_url }}=$(basename "$wheel")" \ + # --data-binary "@$wheel" + # fi + # done