From 7667591a8b60f3ac1c97d94806c0faf747585377 Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Fri, 19 Dec 2025 10:40:06 +0100 Subject: [PATCH 1/4] add update bricks whl file workflow --- .github/workflows/update-bricks-file.yml | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/update-bricks-file.yml diff --git a/.github/workflows/update-bricks-file.yml b/.github/workflows/update-bricks-file.yml new file mode 100644 index 0000000..fca1ce2 --- /dev/null +++ b/.github/workflows/update-bricks-file.yml @@ -0,0 +1,73 @@ +name: Update bricks whl file to the latest version +on: + workflow_dispatch: + schedule: + # Run every day at 8:00 AM UTC + - cron: '0 8 * * *' + pull_request: +permissions: + contents: write + pull-requests: write + +jobs: + steps: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get latest bricks version + id: get-latest-version + run: | + LATEST_RELEASE=$(curl -s https://api.github.com/repos/arduino/app-bricks-py/releases/latest | jq -r .tag_name | sed 's/^release\///') + echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_OUTPUT + + - name: Check if there is an existing branch for the latest version + id: check-branch + run: | + LATEST_RELEASE=${{ steps.get-latest-version.outputs.LATEST_RELEASE }} + if git ls-remote --heads origin update-bricks-${LATEST_RELEASE} | grep -q update-bricks-${LATEST_RELEASE}; then + echo "Branch update-bricks-${LATEST_RELEASE} already exists." + echo "branch_exists=true" >> $GITHUB_OUTPUT + fi + + - name: Check if current version is up to date + if: steps.check-branch.outputs.branch_exists != 'true' + id: check-update + run: | + LATEST_RELEASE=${{ steps.get-latest-version.outputs.LATEST_RELEASE }} + if ls libs/arduino_app_bricks-*.whl 1> /dev/null 2>&1; then + CURRENT_VERSION=$(ls libs/arduino_app_bricks-*.whl | sed -E 's/.*arduino_app_bricks-([0-9]+\.[0-9]+\.[0-9]+)-py3-none-any\.whl/\1/') + echo "CURRENT_VERSION=$CURRENT_VERSION" + if [ "$CURRENT_VERSION" = "$LATEST_RELEASE" ]; then + echo "No update needed. Current version is up to date." + echo "update_needed=false" >> $GITHUB_OUTPUT + exit 0 + fi + fi + echo "Update needed. Current version is outdated or not present." + + - name: Download whl file + if: steps.check-branch.outputs.branch_exists != 'true' && steps.check-update.outputs.update_needed != 'false' + run: | + LATEST_RELEASE=${{ steps.get-latest-version.outputs.LATEST_RELEASE }} + ASSET_URL=$(curl -s https://api.github.com/repos/arduino/app-bricks-py/releases/latest | jq -r '.assets[] | select(.name | endswith(".whl")) | .browser_download_url') + wget "$ASSET_URL" -O libs/arduino_app_bricks-${LATEST_RELEASE}-py3-none-any.whl + + - name: Remove old whl files + if: steps.check-branch.outputs.branch_exists != 'true' && steps.check-update.outputs.update_needed != 'false' + run: | + LATEST_RELEASE=${{ steps.get-latest-version.outputs.LATEST_RELEASE }} + find libs/ -name 'arduino_app_bricks-*.whl' ! -name "arduino_app_bricks-${LATEST_RELEASE}-py3-none-any.whl" -delete + + - name: Create Pull Request + if: steps.check-branch.outputs.branch_exists != 'true' && steps.check-update.outputs.update_needed != 'false' + uses: peter-evans/create-pull-request@v5 + with: + base: main + branch: update-bricks-${{ steps.get-latest-version.outputs.LATEST_RELEASE }} + title: "Update bricks whl file to ${{ steps.get-latest-version.outputs.LATEST_RELEASE }}" + body: "This PR updates the Arduino App Bricks wheel file to the latest version ${{ steps.get-latest-version.outputs.LATEST_RELEASE }}." + commit-message: "Update bricks whl to ${{ steps.get-latest-version.outputs.LATEST_RELEASE }}" + add-paths: | + libs/arduino_app_bricks-*.whl \ No newline at end of file From 1e2e0c6a2c6b9cc75481c09c5d9d6c8f27185adc Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Fri, 19 Dec 2025 11:44:29 +0100 Subject: [PATCH 2/4] make the version generic in the taskfile --- Taskfile.dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index 3717a91..421809c 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -4,7 +4,7 @@ tasks: init:ci: desc: Initialize CI environment cmds: - - pip install libs/arduino_app_bricks-0.6.1-py3-none-any.whl reuse pip-licenses + - pip install libs/arduino_app_bricks-*-py3-none-any.whl reuse pip-licenses license: deps: From 339929c523911a21f22c7c7dd5d1ba85ccdd68bf Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Fri, 19 Dec 2025 11:46:06 +0100 Subject: [PATCH 3/4] remove pull_request trigger --- .github/workflows/update-bricks-file.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update-bricks-file.yml b/.github/workflows/update-bricks-file.yml index fca1ce2..2bf32b9 100644 --- a/.github/workflows/update-bricks-file.yml +++ b/.github/workflows/update-bricks-file.yml @@ -4,7 +4,6 @@ on: schedule: # Run every day at 8:00 AM UTC - cron: '0 8 * * *' - pull_request: permissions: contents: write pull-requests: write From 4676b3680b694bb118b5ca4f9fcd73bdc3607c35 Mon Sep 17 00:00:00 2001 From: Stefano Torneo Date: Fri, 19 Dec 2025 16:56:01 +0100 Subject: [PATCH 4/4] use latest version of ga --- .github/workflows/update-bricks-file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-bricks-file.yml b/.github/workflows/update-bricks-file.yml index 2bf32b9..a01ae06 100644 --- a/.github/workflows/update-bricks-file.yml +++ b/.github/workflows/update-bricks-file.yml @@ -61,7 +61,7 @@ jobs: - name: Create Pull Request if: steps.check-branch.outputs.branch_exists != 'true' && steps.check-update.outputs.update_needed != 'false' - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v8 with: base: main branch: update-bricks-${{ steps.get-latest-version.outputs.LATEST_RELEASE }}