From d6d145a0704e5c146ce0725d6ce9c7dcfae483de Mon Sep 17 00:00:00 2001 From: gavanderhoorn Date: Thu, 27 Jun 2024 12:32:40 +0200 Subject: [PATCH 1/3] ci: use GitHub CLI to download M+ libmicroros Instead of dsaltares/fetch-gh-release-asset. Works just as well and also supports downloading assets from draft releases (which we'll need later). --- .github/workflows/ci_msbuild.yaml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci_msbuild.yaml b/.github/workflows/ci_msbuild.yaml index 159cdc7b..949d57eb 100644 --- a/.github/workflows/ci_msbuild.yaml +++ b/.github/workflows/ci_msbuild.yaml @@ -87,17 +87,14 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: "Download M+ libmicroros (${{ matrix.uros.codename }}-${{ matrix.uros.release }} for ${{ steps.uppercaser.outputs.ctrlr }})" - id: download_libmicroros - uses: dsaltares/fetch-gh-release-asset@1.1.2 - with: - repo: 'yaskawa-global/micro_ros_motoplus' - version: 'tags/release-${{ matrix.uros.codename }}-${{ matrix.controller }}-${{ matrix.uros.release }}' - regex: true - # download the M+ libmicroros distribution for the latest release of - # MotoROS2 corresponding to the controller this workflow is run for - file: "micro_ros_motoplus_${{ matrix.controller }}-${{ matrix.uros.codename }}.*\\.zip" - # work-around for https://github.com/dsaltares/fetch-gh-release-asset/issues/48 - target: "./" + shell: bash + run: | + gh \ + release \ + --repo="yaskawa-global/micro_ros_motoplus" \ + download \ + --pattern="micro_ros_motoplus*.zip" \ + release-${{ matrix.uros.codename }}-${{ matrix.controller }}-${{ matrix.uros.release }} - name: Setup MotoROS2 build dir shell: bash From 778418ff84be8bcc27ee5041ef65556160f30b4b Mon Sep 17 00:00:00 2001 From: gavanderhoorn Date: Thu, 27 Jun 2024 12:45:04 +0200 Subject: [PATCH 2/3] ci: use token to download from other repo GH CLI requires a token to download releases when used in GHA, so acquire one and pass it to GH CLI. --- .github/workflows/ci_msbuild.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci_msbuild.yaml b/.github/workflows/ci_msbuild.yaml index 949d57eb..e9a8afdb 100644 --- a/.github/workflows/ci_msbuild.yaml +++ b/.github/workflows/ci_msbuild.yaml @@ -86,8 +86,19 @@ jobs: - name: Find MSBuild and add to PATH uses: microsoft/setup-msbuild@v2 + - name: Generate token (micro_ros_motoplus) + id: gen_token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.MPLMB_APP_ID }} + private-key: ${{ secrets.MPLMB_APP_PRIVATE_KEY }} + owner: "yaskawa-global" + repositories: "micro_ros_motoplus" + - name: "Download M+ libmicroros (${{ matrix.uros.codename }}-${{ matrix.uros.release }} for ${{ steps.uppercaser.outputs.ctrlr }})" shell: bash + env: + GITHUB_TOKEN: ${{ steps.gen_token.outputs.token }} run: | gh \ release \ From 0e203891312b354c2100f6c7de0569c1dc71fca0 Mon Sep 17 00:00:00 2001 From: gavanderhoorn Date: Thu, 27 Jun 2024 13:11:52 +0200 Subject: [PATCH 3/3] ci: use known name for M+ zip That way we don't have to start looking for it after the download is complete, but can just assume it has a certain name. --- .github/workflows/ci_msbuild.yaml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci_msbuild.yaml b/.github/workflows/ci_msbuild.yaml index e9a8afdb..be7630d6 100644 --- a/.github/workflows/ci_msbuild.yaml +++ b/.github/workflows/ci_msbuild.yaml @@ -105,6 +105,7 @@ jobs: --repo="yaskawa-global/micro_ros_motoplus" \ download \ --pattern="micro_ros_motoplus*.zip" \ + --output="micro_ros_motoplus.zip" \ release-${{ matrix.uros.codename }}-${{ matrix.controller }}-${{ matrix.uros.release }} - name: Setup MotoROS2 build dir @@ -116,25 +117,10 @@ jobs: cp -r "${{ github.workspace }}"/* /c/build/ ls -al /c/build - - name: "Find downloaded M+ libmicroros (${{ matrix.uros.codename }}-${{ matrix.uros.release }} for ${{ steps.uppercaser.outputs.ctrlr }})" - id: find_libmicroros - shell: bash - # bit of a kludge, but works for now. - # we need to do this as 'fetch-gh-release-asset' will try to rename downloaded - # files if we use a regex to match 'unknown' files instead of hard-coding - # everything. - # NOTE: the regex includes the absolute path to the location of the .zip as that's - # how find reports them to the regex engine (because we specify an absolute path - # as the location for find to search for files) - run: | - LIBM_ZIP=$(find /c/build -type f -regextype posix-extended -regex "/c/build/micro_ros_motoplus_${{ matrix.controller }}-${{ matrix.uros.codename }}.*[[:digit:]]+\.zip") - echo "libmicroros_zip=${LIBM_ZIP}" >> $GITHUB_OUTPUT - echo "libmicroros_zip_win=$(cygpath -w ${LIBM_ZIP})" >> $GITHUB_OUTPUT - echo "Found libmicroros zip: '${LIBM_ZIP}'" - name: Extract M+ libmicroros distribution shell: bash run: | - unzip -q "${{ steps.find_libmicroros.outputs.libmicroros_zip }}" \ + unzip -q /c/build/micro_ros_motoplus.zip \ -d /c/build/motoros2/libmicroros_${{ matrix.controller }}_${{ matrix.uros.codename }} - name: Download and setup M+ SDK (mpBuilder)