[PLAT-17384] Fixing the CI system to generate aarch64 and x86_64 builds for glibc < 2.28 #63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - Build earlyoom for yugabytedb | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| env: | |
| BUILD_DIR: dist | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [amd64, arm64] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set platform-specific env | |
| run: | | |
| echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
| echo "TARGET=earlyoom-linux-${{ matrix.arch }}" >> $GITHUB_ENV | |
| echo "VERSION=v999-dev-$(git describe --tags --dirty --always || echo vdev)" >> $GITHUB_ENV | |
| - name: Set up QEMU (for ARM builds) | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build binaries inside containers | |
| run: | | |
| if [ "${{ matrix.arch }}" = "amd64" ]; then | |
| docker run --rm -v $PWD:/work -w /work almalinux:8 \ | |
| /bin/bash -c "dnf install -y gcc gcc-c++ make git tar gzip && make clean && make" | |
| else | |
| docker run --rm -v $PWD:/work -w /work ubuntu:18.04 \ | |
| /bin/bash -c "apt-get update && apt-get install -y build-essential gcc-aarch64-linux-gnu && make clean && make CC=aarch64-linux-gnu-gcc" | |
| fi | |
| - name: Package binary | |
| run: | | |
| mkdir -p $BUILD_DIR/earlyoom-${VERSION} | |
| cp earlyoom $BUILD_DIR/earlyoom-${VERSION}/ | |
| tar czvf $BUILD_DIR/${TARGET}.tar.gz -C $BUILD_DIR earlyoom-${VERSION} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: earlyoom-${{ matrix.arch }} | |
| path: ${{ env.BUILD_DIR }}/${{ env.TARGET }}.tar.gz | |
| - name: Upload artifact to GitHub Release (create if needed) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG_NAME="${GITHUB_REF#refs/tags/}" | |
| sudo apt-get update | |
| sudo apt-get install -y gh | |
| set +e | |
| echo "Trying to upload to existing release..." | |
| gh release upload "$TAG_NAME" ${{ env.BUILD_DIR }}/${{ env.TARGET }}.tar.gz --clobber | |
| STATUS=$? | |
| set -e | |
| if [ $STATUS -ne 0 ]; then | |
| echo "Release does not exist, creating new release..." | |
| gh release create "$TAG_NAME" ${{ env.BUILD_DIR }}/${{ env.TARGET }}.tar.gz \ | |
| --title "$TAG_NAME" \ | |
| --notes "Automated release for $TAG_NAME" \ | |
| --latest | |
| fi | |