diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c55f2c45c4..28be095cb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,49 +1,47 @@ name: Release on: - release: - types: - - published + push: + tags: + - 'v*' + +permissions: + contents: write jobs: - build-assets-linux-amd64: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Download earthly - run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.21/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" - - name: Set output - id: vars - run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT - - name: Build amd64 assets - run: earthly --platform=linux/amd64 +libphonenumber - - name: Upload linux/amd64 assets - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - run: gh release upload --clobber ${{steps.vars.outputs.tag}} "cpp/build/assets_linux_amd64.zip" - build-asset-linux-arm64: + linux: runs-on: ubuntu-latest - permissions: - contents: write + strategy: + matrix: + os: [alpine-3.17, ubuntu-20.04, ubuntu-22.04] + platform: [linux/amd64] + include: + - os: alpine-3.17 + platform: linux/arm64 steps: - name: Checkout repository uses: actions/checkout@v3 - name: Download earthly run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.21/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" - - name: Set output - id: vars - run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT + - name: Get tag + run: echo TAG=${GITHUB_REF#refs/*/} >> $GITHUB_ENV + - name: Get version + run: echo VERSION=${TAG#v} >> $GITHUB_ENV - name: Set up QEMU + if: ${{ matrix.platform == 'linux/arm64' }} uses: docker/setup-qemu-action@v1 with: image: tonistiigi/binfmt:latest - platforms: all - - name: Build arm64 assets - run: earthly --platform=linux/arm64 +libphonenumber - - name: Upload linux/arm64 assets - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - run: gh release upload --clobber ${{steps.vars.outputs.tag}} "cpp/build/assets_linux_arm64.zip" + platforms: arm64 + - name: Build ${{matrix.os}} - ${{matrix.platform}} assets + run: earthly --platform=${{matrix.platform}} +libphonenumber --buildos=${{matrix.os}} + - name: Build deb package + if: ${{ contains(matrix.os, 'ubuntu') }} + run: earthly --platform=${{matrix.platform}} +libphonenumber-deb --buildos=${{matrix.os}} --version=${{env.VERSION}} + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + cpp/build/*.zip + cpp/build/*.deb diff --git a/Earthfile b/Earthfile index 1b610003df..e19cb9f550 100644 --- a/Earthfile +++ b/Earthfile @@ -1,34 +1,88 @@ VERSION 0.5 -alpine-base: - FROM --platform=$BUILDPLATFORM alpine:3.17 - RUN apk add --no-progress --update git build-base zip - RUN apk --no-cache --update add libgcc libstdc++ \ - git make g++ \ - build-base gtest gtest-dev boost boost-dev protobuf protobuf-dev cmake icu icu-dev openssl \ - && \ - rm -rf /var/cache/apk/* - RUN apk add openjdk8-jre +alpine-3.17: + FROM --platform=$BUILDPLATFORM alpine:3.17 + RUN apk add --no-progress --update git build-base zip + RUN apk --no-cache --update add libgcc libstdc++ \ + git make g++ \ + build-base gtest gtest-dev boost boost-dev protobuf protobuf-dev cmake icu icu-dev openssl \ + && \ + rm -rf /var/cache/apk/* + RUN apk add openjdk8-jre + +ubuntu-20.04: + FROM --platform=$BUILDPLATFORM ubuntu:20.04 + RUN apt-get update && apt-get -y upgrade + RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata + RUN apt-get -y install \ + build-essential pkg-config git zip hashdeep \ + cmake cmake-curses-gui libprotobuf-dev libgtest-dev libre2-dev \ + libicu-dev libboost-dev libboost-thread-dev libboost-system-dev openssl \ + protobuf-compiler openjdk-8-jre + RUN rm -rf /var/cache/apt/* + +ubuntu-22.04: + FROM --platform=$BUILDPLATFORM ubuntu:22.04 + RUN apt-get update && apt-get -y upgrade + RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata + RUN apt-get -y install \ + build-essential pkg-config git zip hashdeep \ + cmake cmake-curses-gui libprotobuf-dev libgtest-dev libre2-dev \ + libicu-dev libboost-dev libboost-thread-dev libboost-system-dev openssl \ + protobuf-compiler openjdk-8-jre + RUN rm -rf /var/cache/apt/* libphonenumber: - FROM +alpine-base + ARG TARGETARCH + ARG --required buildos + + FROM +${buildos} + + WORKDIR /libphonenumber + COPY --dir . . + + # kludge: COPY creates files in the past causing make not rebuild some resources + # RUN find . -print0 | xargs -0 touch + RUN touch /libphonenumber/resources/PhoneNumberMetadata.xml + + WORKDIR /libphonenumber/cpp/build + RUN mkdir assets + RUN cmake -DCMAKE_INSTALL_PREFIX:PATH=./assets .. + RUN make install + + WORKDIR assets + RUN zip -r ../libphonenumber_${TARGETARCH}-${buildos}.zip * + + SAVE ARTIFACT /libphonenumber/cpp/build/libphonenumber_${TARGETARCH}-${buildos}.zip AS LOCAL cpp/build/libphonenumber_${TARGETARCH}-${buildos}.zip - ARG TARGETOS - ARG TARGETARCH +libphonenumber-deb: + ARG TARGETARCH + ARG --required buildos + ARG --required version - WORKDIR /libphonenumber - COPY --dir . . + FROM +${buildos} - # kludge: COPY creates files in the past causing make not rebuild some resources - # RUN find . -print0 | xargs -0 touch - RUN touch /libphonenumber/resources/PhoneNumberMetadata.xml + WORKDIR /deb + COPY cpp/build/libphonenumber_*.zip . + RUN unzip libphonenumber_*.zip -d phonenumbers - WORKDIR /libphonenumber/cpp/build - RUN mkdir assets - RUN cmake -DCMAKE_INSTALL_PREFIX:PATH=./assets .. - RUN make install + WORKDIR /deb/phonenumbers + RUN mkdir -p usr/local + RUN mv include lib usr/local + RUN mkdir DEBIAN + RUN md5deep -lr usr > DEBIAN/md5sums + RUN echo "\ +Package: phonenumbers +Version: ${version} +Maintainer: annatel +Architecture: ${TARGETARCH} +Section: libs +Description: Annatel phonenumbers library + Annatel phonenumbers library with extended numbers +Depends: protobuf-compiler, libboost-thread-dev +" > DEBIAN/control - WORKDIR assets - RUN zip -r ../assets_${TARGETOS}_${TARGETARCH}.zip * + WORKDIR /deb + RUN fakeroot dpkg-deb --build phonenumbers - SAVE ARTIFACT /libphonenumber/cpp/build/assets_${TARGETOS}_${TARGETARCH}.zip AS LOCAL cpp/build/assets_${TARGETOS}_${TARGETARCH}.zip + SAVE ARTIFACT /deb/phonenumbers.deb AS LOCAL cpp/build/libphonenumber_${TARGETARCH}-${buildos}.deb