|
| 1 | +name: Build and Deploy for Raspberry Pi |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-deploy: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + submodules: false |
| 19 | + |
| 20 | + - name: Set up QEMU |
| 21 | + uses: docker/setup-qemu-action@v2 |
| 22 | + with: |
| 23 | + platforms: linux/arm64 |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v3 |
| 27 | + |
| 28 | + - name: Build Docker image for ARM64 |
| 29 | + run: | |
| 30 | + docker buildx build \ |
| 31 | + -f ./RaspberryPi/deploy/dockerfiles/DockerfileDeployRasp \ |
| 32 | + --platform linux/arm64 --load \ |
| 33 | + --build-arg projectDir=$PWD/$PROJECT_DIR \ |
| 34 | + -t final-app . |
| 35 | +
|
| 36 | + - name: Extract built binaries |
| 37 | + run: | |
| 38 | + mkdir -p artifacts/bin |
| 39 | + mkdir -p artifacts/config |
| 40 | + mkdir -p artifacts/fonts |
| 41 | +
|
| 42 | + docker create --name tmpapp final-app |
| 43 | +
|
| 44 | + docker cp tmpapp:/home/$PROJECT_DIR/InstrumentClusterApp ./artifacts/bin/ |
| 45 | + docker cp tmpapp:/home/$PROJECT_DIR/MiddleWareApp ./artifacts/bin/ |
| 46 | +
|
| 47 | + cp ./$PROJECT_DIR/ZenohConfig/InstrumentClusterConfig.json ./artifacts/config/ |
| 48 | + cp ./$PROJECT_DIR/ZenohConfig/MiddleWareConfig.json ./artifacts/config/ |
| 49 | +
|
| 50 | + cp -r ./RaspberryPi/deploy/fonts/* ./artifacts/fonts/ |
| 51 | +
|
| 52 | + git archive --format=zip HEAD -o ./artifacts/source-code.zip |
| 53 | +
|
| 54 | + cd artifacts |
| 55 | + zip -r ../release-package.zip * |
| 56 | + cd .. |
| 57 | +
|
| 58 | + docker rm tmpapp |
| 59 | +
|
| 60 | + - name: Get latest tag and increment |
| 61 | + id: tag |
| 62 | + run: | |
| 63 | + git fetch --tags --force |
| 64 | + git fetch origin |
| 65 | + latest_tag=$(git tag --sort=-v:refname | head -n 1) |
| 66 | + if [ -z "$latest_tag" ]; then |
| 67 | + latest_tag="v1.0.0" |
| 68 | + fi |
| 69 | + major=$(echo $latest_tag | cut -d. -f1 | tr -d 'v') |
| 70 | + minor=$(echo $latest_tag | cut -d. -f2) |
| 71 | + patch=$(echo $latest_tag | cut -d. -f3) |
| 72 | + new_tag="v$major.$minor.$((patch + 1))" |
| 73 | + echo "new_tag=$new_tag" >> $GITHUB_OUTPUT |
| 74 | +
|
| 75 | + - name: Create GitHub Release |
| 76 | + uses: softprops/action-gh-release@v1 |
| 77 | + with: |
| 78 | + tag_name: ${{ steps.tag.outputs.new_tag }} |
| 79 | + name: Release ${{ steps.tag.outputs.new_tag }} |
| 80 | + body: | |
| 81 | + ## Raspberry Pi Release |
| 82 | +
|
| 83 | + **Includes:** |
| 84 | + - Compiled apps (`InstrumentClusterApp`, `MiddleWareApp`) |
| 85 | + - Zenoh config files |
| 86 | + - Fonts |
| 87 | + - Full source code zip |
| 88 | +
|
| 89 | + **Instructions:** |
| 90 | + - Copy `InstrumentClusterApp` and `MiddleWareApp` to `$PI_PATH_BIN` |
| 91 | + - Copy configs to `$PI_PATH_ETC` |
| 92 | + - Copy fonts to `$PI_PATH_FONTS` |
| 93 | + files: | |
| 94 | + release-package.zip |
| 95 | + artifacts/source-code.zip |
| 96 | + artifacts/bin/* |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.PAT_LUIS }} |
0 commit comments