|
| 1 | +name: Build & Update with Arduino CLI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - test_package_update |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-and-update: |
| 15 | + runs-on: ubuntu-22.04 |
| 16 | + services: |
| 17 | + docker: |
| 18 | + image: docker:dind |
| 19 | + options: --privileged --shm-size=2g |
| 20 | + volumes: |
| 21 | + - /var/run/docker.sock:/var/run/docker.sock:ro |
| 22 | + container: |
| 23 | + image: ubuntu:latest |
| 24 | + |
| 25 | + env: |
| 26 | + ARCH: amd64 |
| 27 | + APPCLI_REPO: arduino/arduino-app-cli |
| 28 | + ROUTER_REPO: arduino/arduino-router |
| 29 | + STABLE_DIR: build/stable |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Docker |
| 36 | + uses: docker/setup-docker-action@v2 |
| 37 | + |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@v3 |
| 40 | + |
| 41 | + - name: Build Docker image (no cache) |
| 42 | + run: | |
| 43 | + docker build --no-cache -t mock-apt-repo -f test.Dockerfile . |
| 44 | +
|
| 45 | + - name: Ensure tools on runner |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y jq curl docker.io |
| 49 | +
|
| 50 | + - name: Install Task (go-task) |
| 51 | + run: | |
| 52 | + curl -sL https://taskfile.dev/install.sh | sh -s -- -d -b ./bin |
| 53 | + echo "$PWD/bin" >> $GITHUB_PATH |
| 54 | + task --version |
| 55 | +
|
| 56 | + - name: Prepare folder |
| 57 | + run: | |
| 58 | + mkdir -p "${STABLE_DIR}" |
| 59 | +
|
| 60 | + - name: Checkout |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Ensure curl & mkdir |
| 64 | + run: | |
| 65 | + sudo apt-get update |
| 66 | + sudo apt-get install -y curl |
| 67 | + mkdir -p "$STABLE_DIR" |
| 68 | +
|
| 69 | + # --- Arduino App CLI (.deb) --- |
| 70 | + - name: Download arduino-app-cli .deb (from hard-coded tag page) |
| 71 | + run: | |
| 72 | + set -euo pipefail |
| 73 | + BASE="https://github.com/arduino/arduino-app-cli" |
| 74 | + # Use the "expanded_assets" page for the tag to get direct links |
| 75 | + PAGE="$BASE/releases/expanded_assets/${TAG}" |
| 76 | + REL_URL=$(curl -fsSL "$PAGE" | grep -oE '/arduino/arduino-app-cli/releases/download/'"$TAG"'/[^"]+\.deb' | head -n1) |
| 77 | + test -n "$REL_URL" |
| 78 | + URL="https://github.com${REL_URL}" |
| 79 | + echo "Found asset: $URL" |
| 80 | + curl -fL "$URL" -o "$STABLE_DIR/arduino-app-cli_${TAG}.deb" |
| 81 | + ls -l "$STABLE_DIR" |
| 82 | +
|
| 83 | + # --- Arduino Router (.deb) --- |
| 84 | + - name: Download arduino-router .deb (from hard-coded tag page) |
| 85 | + run: | |
| 86 | + set -euo pipefail |
| 87 | + BASE="https://github.com/arduino/arduino-router" |
| 88 | + PAGE="$BASE/releases/expanded_assets/${TAG}" |
| 89 | + REL_URL=$(curl -fsSL "$PAGE" | grep -oE '/arduino/arduino-router/releases/download/'"$TAG"'/[^"]+\.deb' | head -n1) |
| 90 | + test -n "$REL_URL" |
| 91 | + URL="https://github.com${REL_URL}" |
| 92 | + echo "Found asset: $URL" |
| 93 | + curl -fL "$URL" -o "$STABLE_DIR/arduino-router_${TAG}.deb" |
| 94 | + ls -l "$STABLE_DIR" |
| 95 | +
|
| 96 | + |
| 97 | + - name: Run mock-apt-repo container |
| 98 | + run: | |
| 99 | + docker run --rm -d \ |
| 100 | + --privileged \ |
| 101 | + --cgroupns=host \ |
| 102 | + -v /sys/fs/cgroup:/sys/fs/cgroup:rw \ |
| 103 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 104 | + -e DOCKER_HOST=unix:///var/run/docker.sock \ |
| 105 | + --name apt-test-update \ |
| 106 | + mock-apt-repo |
| 107 | +
|
| 108 | + - name: Verify container is running |
| 109 | + run: docker ps |
0 commit comments