|
| 1 | +name: arch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + outputs: |
| 6 | + name: |
| 7 | + description: "The artifact name" |
| 8 | + value: ${{ jobs.build_arch.outputs.name }} |
| 9 | + |
| 10 | +env: |
| 11 | + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 12 | + |
| 13 | +jobs: |
| 14 | + build_arch: |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + - arch: aarch64 |
| 18 | + distro: ubuntu22.04 |
| 19 | + - arch: aarch64 |
| 20 | + distro: bullseye |
| 21 | + |
| 22 | + # See: https://docs.github.com/zh/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners |
| 23 | + # See: https://github.com/actions/runner-images/ |
| 24 | + runs-on: ubuntu-24.04 |
| 25 | + |
| 26 | + env: |
| 27 | + BUILD_TYPE: ${{matrix.BUILD_TYPE}} |
| 28 | + SOURCE_DIR: ${{github.workspace}}/.cache/source |
| 29 | + TOOLS_DIR: ${{github.workspace}}/.cache/tools |
| 30 | + INSTALL_DIR: ${{github.workspace}}/.cache/install |
| 31 | + RabbitRemoteControl_VERSION: v0.0.32 |
| 32 | + artifact_name: build_appimage |
| 33 | + |
| 34 | + # Map the job outputs to step outputs |
| 35 | + outputs: |
| 36 | + name: ${{ env.artifact_name }} |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout Repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + submodules: true |
| 43 | + |
| 44 | + - name: Make directories |
| 45 | + run: | |
| 46 | + cmake -E make_directory ${{github.workspace}}/build |
| 47 | + cmake -E make_directory ${{env.SOURCE_DIR}} |
| 48 | + cmake -E make_directory ${{env.TOOLS_DIR}} |
| 49 | + cmake -E make_directory ${{env.INSTALL_DIR}} |
| 50 | +
|
| 51 | + - name: git clone RabbitCommon |
| 52 | + working-directory: ${{env.SOURCE_DIR}} |
| 53 | + run: | |
| 54 | + git clone https://github.com/KangLin/RabbitCommon.git |
| 55 | +
|
| 56 | + - uses: uraimo/run-on-arch-action@v2 |
| 57 | + name: Build artifact |
| 58 | + id: build |
| 59 | + with: |
| 60 | + arch: ${{ matrix.arch }} |
| 61 | + distro: ${{ matrix.distro }} |
| 62 | + |
| 63 | + # Not required, but speeds up builds |
| 64 | + githubToken: ${{secrets.GITHUB_TOKEN}} |
| 65 | + |
| 66 | + # Create an artifacts directory |
| 67 | + setup: | |
| 68 | + mkdir -p "${PWD}/artifacts" |
| 69 | +
|
| 70 | + # Mount the artifacts directory as /artifacts in the container |
| 71 | + dockerRunArgs: | |
| 72 | + --volume "${PWD}/artifacts:/artifacts" |
| 73 | +
|
| 74 | + # Pass some environment variables to the container |
| 75 | + env: | # YAML, but pipe character is necessary |
| 76 | + artifact_name: git-${{ matrix.distro }}_${{ matrix.arch }} |
| 77 | + RabbitCommon_ROOT: ${{env.SOURCE_DIR}}/RabbitCommon |
| 78 | +
|
| 79 | + # The shell to run commands with in the container |
| 80 | + shell: /bin/bash |
| 81 | + |
| 82 | + # Install some dependencies in the container. This speeds up builds if |
| 83 | + # you are also using githubToken. Any dependencies installed here will |
| 84 | + # be part of the container image that gets cached, so subsequent |
| 85 | + # builds don't have to re-install them. The image layer is cached |
| 86 | + # publicly in your project's package repository, so it is vital that |
| 87 | + # no secrets are present in the container state or logs. |
| 88 | + install: | |
| 89 | + case "${{ matrix.distro }}" in |
| 90 | + ubuntu*|jessie|stretch|buster|bullseye) |
| 91 | + apt-get update -q -y |
| 92 | + apt-get install -q -y git |
| 93 | + ;; |
| 94 | + fedora*) |
| 95 | + dnf -y update |
| 96 | + dnf -y install git which |
| 97 | + ;; |
| 98 | + alpine*) |
| 99 | + apk update |
| 100 | + apk add git |
| 101 | + ;; |
| 102 | + esac |
| 103 | +
|
| 104 | + # Produce a binary artifact and place it in the mounted volume |
| 105 | + run: | |
| 106 | + cp $(which git) "/artifacts/${artifact_name}" |
| 107 | + echo "Produced artifact at /artifacts/${artifact_name}" |
| 108 | +
|
| 109 | + - name: Show the artifact |
| 110 | + # Items placed in /artifacts in the container will be in |
| 111 | + # ${PWD}/artifacts on the host. |
| 112 | + run: | |
| 113 | + ls -al "${PWD}/artifacts" |
0 commit comments