From dc2615673dee8c2e9b8eed41ed5daa6087746ea7 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Thu, 11 Aug 2022 14:22:18 +0200 Subject: [PATCH] update workflow for release --- .../actions/add-version-to-channel/action.yml | 6 ++ .github/workflows/firmware.yaml | 60 ++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/.github/actions/add-version-to-channel/action.yml b/.github/actions/add-version-to-channel/action.yml index 9349dc889..11e5a8457 100644 --- a/.github/actions/add-version-to-channel/action.yml +++ b/.github/actions/add-version-to-channel/action.yml @@ -20,6 +20,12 @@ inputs: runs: using: "composite" steps: + - name: Install Prerequisites + shell: bash + run: | + pip install aiohttp cryptography + pip install odrive --pre + - name: Register on release server shell: python run: | diff --git a/.github/workflows/firmware.yaml b/.github/workflows/firmware.yaml index 61dfeedd4..90f3e4002 100644 --- a/.github/workflows/firmware.yaml +++ b/.github/workflows/firmware.yaml @@ -27,11 +27,29 @@ jobs: - {os: ubuntu-latest, board_version: v3.6-56V, debug: false} runs-on: ${{ matrix.os }} + outputs: + channel: ${{ steps.release-info.outputs.channel }} + version: ${{ steps.release-info.outputs.version }} steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # fetch entire history to get version information + - name: Get release name and channel + id: release-info + shell: python + run: | + if "${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/fw-v0.5.') }}" == "true": + channel = "master" + version = "${{ github.ref }}"[len("refs/tags/fw-v"):] + + else: + channel = "none" + version = "${{ github.sha }}" + + print("::set-output name=channel::" + channel) + print("::set-output name=version::" + version) + - name: Install prerequisites (Debian) if: startsWith(matrix.os, 'ubuntu-') run: | @@ -114,7 +132,7 @@ jobs: mv tup_build.sh tup_build.bat # in reality this is a .bat script on windows .\tup_build.bat - - name: Upload binary + - name: Upload binary as artifact if: ${{ matrix.os == 'ubuntu-latest' && matrix.debug == false }} uses: actions/upload-artifact@v2 with: @@ -124,6 +142,46 @@ jobs: Firmware/build/ODriveFirmware.bin Firmware/build/ODriveFirmware.hex + - name: Copy firmware to temp folder + run: | + mkdir ${{ github.workspace }}/out + cp ${{ github.workspace }}/Firmware/build/ODriveFirmware.elf ${{ github.workspace }}/out/firmware.elf + + - name: Upload firmware to ODrive release system + if: ${{ steps.release-info.outputs.channel == 'master' && matrix.os == 'ubuntu-latest' && matrix.debug == false && (startsWith(matrix.board_version, 'v3.5-') || startsWith(matrix.board_version, 'v3.6-')) }} + uses: ./.github/actions/upload-release + with: + release_type: firmware + version: ${{ steps.release-info.outputs.version }} + src_dir: out + do_access_key: ${{ secrets.DIGITALOCEAN_ACCESS_KEY }} + do_secret_key: ${{ secrets.DIGITALOCEAN_SECRET_KEY }} + odrive_api_key: ${{ secrets.ODRIVE_API_KEY }} + product: ODrive ${{ matrix.board_version }} + app: default + variant: public + + make-release: + needs: [compile] # require all builds to succeed before we actually make the release + if: needs.compile.outputs.channel == 'master' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout git repository + uses: actions/checkout@v2 + + - name: Install Python dependencies + run: pip install aiohttp appdirs + + - name: Add version to release channel + uses: ./.github/actions/add-version-to-channel + with: + release_type: firmware + channel: ${{ needs.compile.outputs.channel }} + version: ${{ needs.compile.outputs.version }} + odrive_api_key: ${{ secrets.ODRIVE_API_KEY }} + code-checks: strategy: fail-fast: false