Skip to content

Commit 2ff19d9

Browse files
committed
Annatel internal changes
1 parent 4b420cc commit 2ff19d9

5 files changed

Lines changed: 206 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
linux:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
os: [alpine-3.21, ubuntu-20.04, ubuntu-22.04]
17+
platform: [linux/amd64]
18+
include:
19+
- os: alpine-3.21
20+
platform: linux/arm64
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v3
24+
- name: Download earthly
25+
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'"
26+
- name: Get tag
27+
run: echo TAG=${GITHUB_REF#refs/*/} >> $GITHUB_ENV
28+
- name: Get version
29+
run: echo VERSION=${TAG#v} >> $GITHUB_ENV
30+
- name: Set up QEMU
31+
if: ${{ matrix.platform == 'linux/arm64' }}
32+
uses: docker/setup-qemu-action@v1
33+
with:
34+
image: tonistiigi/binfmt:latest
35+
platforms: arm64
36+
- name: Build ${{matrix.os}} - ${{matrix.platform}} assets
37+
run: earthly --platform=${{matrix.platform}} +libphonenumber --buildos=${{matrix.os}}
38+
- name: Build deb package
39+
if: ${{ contains(matrix.os, 'ubuntu') }}
40+
run: earthly --platform=${{matrix.platform}} +libphonenumber-deb --buildos=${{matrix.os}} --version=${{env.VERSION}}
41+
- name: Release
42+
uses: softprops/action-gh-release@v1
43+
if: startsWith(github.ref, 'refs/tags/')
44+
with:
45+
files: |
46+
cpp/build/*.zip
47+
cpp/build/*.deb

Earthfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
VERSION 0.6
2+
3+
alpine-3.21:
4+
FROM --platform=$BUILDPLATFORM alpine:3.21
5+
RUN apk add --no-progress --update git build-base zip
6+
RUN apk --no-cache --update add libgcc libstdc++ \
7+
git make g++ \
8+
build-base gtest gtest-dev boost boost-dev protobuf protobuf-dev cmake icu icu-dev openssl \
9+
&& \
10+
rm -rf /var/cache/apk/*
11+
RUN apk add openjdk8-jre
12+
ENV ABSL_HOTFIX=absl::absl_check
13+
14+
ubuntu-20.04:
15+
FROM --platform=$BUILDPLATFORM ubuntu:20.04
16+
RUN apt-get update && apt-get -y upgrade
17+
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
18+
RUN apt-get -y install \
19+
build-essential pkg-config git zip hashdeep \
20+
cmake cmake-curses-gui libprotobuf-dev libgtest-dev libre2-dev \
21+
libicu-dev libboost-dev libboost-thread-dev libboost-system-dev openssl \
22+
protobuf-compiler openjdk-8-jre
23+
RUN rm -rf /var/cache/apt/*
24+
25+
ubuntu-22.04:
26+
FROM --platform=$BUILDPLATFORM ubuntu:22.04
27+
RUN apt-get update && apt-get -y upgrade
28+
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
29+
RUN apt-get -y install \
30+
build-essential pkg-config git zip hashdeep \
31+
cmake cmake-curses-gui libprotobuf-dev libgtest-dev libre2-dev \
32+
libicu-dev libboost-dev libboost-thread-dev libboost-system-dev openssl \
33+
protobuf-compiler openjdk-8-jre
34+
RUN rm -rf /var/cache/apt/*
35+
36+
libphonenumber:
37+
ARG TARGETARCH
38+
ARG --required buildos
39+
40+
FROM +${buildos}
41+
42+
WORKDIR /libphonenumber
43+
COPY --dir . .
44+
45+
# kludge: COPY creates files in the past causing make not rebuild some resources
46+
# RUN find . -print0 | xargs -0 touch
47+
RUN touch /libphonenumber/resources/PhoneNumberMetadata.xml
48+
49+
WORKDIR /libphonenumber/cpp/build
50+
RUN mkdir assets
51+
RUN cmake -DABSL_HOTFIX=${ABSL_HOTFIX} -DCMAKE_INSTALL_PREFIX:PATH=./assets ..
52+
RUN make install
53+
54+
WORKDIR assets
55+
RUN rm -rf lib/cmake
56+
RUN zip -r ../libphonenumber_${TARGETARCH}-${buildos}.zip *
57+
58+
SAVE ARTIFACT /libphonenumber/cpp/build/libphonenumber_${TARGETARCH}-${buildos}.zip AS LOCAL cpp/build/libphonenumber_${TARGETARCH}-${buildos}.zip
59+
60+
libphonenumber-deb:
61+
ARG TARGETARCH
62+
ARG --required buildos
63+
ARG --required version
64+
65+
FROM +${buildos}
66+
67+
WORKDIR /deb
68+
COPY cpp/build/libphonenumber_*.zip .
69+
RUN unzip libphonenumber_*.zip -d phonenumbers
70+
71+
WORKDIR /deb/phonenumbers
72+
RUN mkdir -p usr/local
73+
RUN mv include lib usr/local
74+
RUN mkdir DEBIAN
75+
RUN md5deep -lr usr > DEBIAN/md5sums
76+
RUN echo "\
77+
Package: phonenumbers
78+
Version: ${version}
79+
Maintainer: annatel <support@annatel.net>
80+
Architecture: ${TARGETARCH}
81+
Section: libs
82+
Description: Annatel phonenumbers library
83+
Annatel phonenumbers library with extended numbers
84+
Depends: protobuf-compiler, libboost-thread-dev
85+
" > DEBIAN/control
86+
87+
WORKDIR /deb
88+
RUN fakeroot dpkg-deb --build phonenumbers
89+
90+
SAVE ARTIFACT /deb/phonenumbers.deb AS LOCAL cpp/build/libphonenumber_${TARGETARCH}-${buildos}.deb

README-Annatel.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Updating to a new version of Google's libphonenumber
2+
3+
## Prepare the repo with required version and Annatel's changes
4+
5+
- If you don't already have it, get Annatel's fork of libphonenumber : `git clone git@github.com:annatel/libphonenumber.git`
6+
- cd libphonenumber/
7+
- If you didn't already add it, add Google's version as upstream : `git remote add upstream git@github.com:google/libphonenumber.git`
8+
- fetch all changes and tags : `git fetch --all --tag`
9+
- find what was the latest version from Annatel (e.g. vP.RE.V) : `git branch -r | grep antl`
10+
- checkout that version : `git checkout vP.RE.V`
11+
- update it to latest commit: `git pull`
12+
- create a local branch for your new version basing it ont the tag from Google that you're interested in (e.g. vL.AS.T): `git checkout -b antl-vL.AS.T vL.AS.T`
13+
- apply Annatel's diff to your new branch : `git diff vP.RE.V..antl-vP.RE.V | git apply -`
14+
If it doesn't work automatically you'll have to do it manually, try that alternative procedure :
15+
- `git diff vP.RE.V..antl-P.RE.V > patch.diff`
16+
- edit patch.diff, save all hunks that are not problematic in a new file named p1.diff and the problematic ones in p2.diff
17+
- `git apply p1.diff`
18+
- manually apply p2.diff (probably changes regarding `resources/PhoneNumberMetadata.xml` — WARNING: do **NOT** put comments inside tags)
19+
- if you need to add other changes, add them now.(find other ranges (i.e. M2M, IOT...) at : https://data.gov.il/dataset/israel-numbering-plan/resource/74b44725-d8cc-4ae9-ba08-2c40a61ab68e)
20+
- check that the changes look good; you should see a small number (~4) of new or changed files: `git status`
21+
- if you need to do other changes, fix previous changes, etc, do it now. If you see that there is a previously added hotfix, try to see if it is possible to remove it with this new version
22+
- add the files to a new commit : `git add .github/workflows/release.yml Earthfile resources/PhoneNumberMetadata.xml README-Annatel.md ... your files`
23+
- commit : `git commit -m "Annatel internal changes"`
24+
- push your new branch : `git push --set-upstream origin antl-vL.AS.T`
25+
26+
## Release the new version
27+
28+
- go to https://github.com/annatel/libphonenumber/
29+
- In the right colmn, click on "Releases"
30+
- click on "Draft a new release"
31+
- click on the "Choose a tag" dropdown
32+
- in the "Find or create a new tag" field enter a name for the tag of the new release, (e.g. vL.AS.T-antl-0.42.0)
33+
- click on the "Target: master" dropdown
34+
- in the "Branches" tab, chose the branch you created earlier (e.g. antl-vL.AS.T)
35+
- click on the "Publish release" button
36+
- you should now see the page of the release you just created but the assets.zip file is not there yet in the "Assets" files list
37+
- wait approximately 5 minutes (You can check if it is finished in the "Actions" tab)
38+
- reload the page of the release
39+
- you should now see the assets.zip file in the "Assets" file list
40+
- done ✅
41+
42+
## Check the new version
43+
44+
Update antl_phonenumber:
45+
- go to your antl_phonenumber worktree and update it : `cd ../antl_phonenumber && git pull`
46+
- **if you changed Google's metadata, add relevant test numbers to `test/annatel_test_numbers.csv`**
47+
- update `Earthfile` to use your new version of the libphonenumber assets
48+
- check that all tests pass **with earthly** (it will automatically add Annatel specific tests) : `earthly -P +test`
49+
50+
51+
## Use the new version
52+
53+
You can now update the Earthfile of your projects with the url of the new assets.zip file.
54+
55+
Be carefull, it often appears twice in internal projects Earthfiles.
56+

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ include_directories ("src")
427427
# Collate dependencies
428428
#----------------------------------------------------------------
429429

430-
set (LIBRARY_DEPS ${ICU_LIB} ${PROTOBUF_LIB} absl::node_hash_set absl::strings absl::synchronization)
430+
set (LIBRARY_DEPS ${ICU_LIB} ${PROTOBUF_LIB} absl::node_hash_set absl::strings absl::synchronization ${ABSL_HOTFIX})
431431

432432
if (USE_BOOST)
433433
list (APPEND LIBRARY_DEPS ${Boost_LIBRARIES})

resources/PhoneNumberMetadata.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14361,7 +14361,7 @@
1436114361
</numberFormat>
1436214362
<!-- Variable cost (premium rate, toll free etc.) -->
1436314363
<numberFormat pattern="(\d)(\d{3})(\d{3})(\d{3})">
14364-
<leadingDigits>1[7-9]</leadingDigits>
14364+
<leadingDigits>1[37-9]</leadingDigits>
1436514365
<format>$1-$2-$3-$4</format>
1436614366
</numberFormat>
1436714367
<!-- Format is from http://everything.explained.today/Telephone_numbers_in_Israel/
@@ -14411,6 +14411,11 @@
1441114411
<possibleLengths national="9"/>
1441214412
<exampleNumber>502345678</exampleNumber>
1441314413
<nationalNumberPattern>
14414+
501\d{6}|
14415+
521\d{6}|
14416+
54[01]\d{6}|
14417+
551[6789]\d{5}|
14418+
58[01]\d{6}|
1441414419
55(?:
1441514420
4(?:
1441614421
[01]0|
@@ -14471,7 +14476,12 @@
1447114476
<sharedCost>
1447214477
<possibleLengths national="10"/>
1447314478
<exampleNumber>1700123456</exampleNumber>
14474-
<nationalNumberPattern>1700\d{6}</nationalNumberPattern>
14479+
<nationalNumberPattern>
14480+
1(?:
14481+
30[23]|
14482+
700
14483+
)\d{6}
14484+
</nationalNumberPattern>
1447514485
</sharedCost>
1447614486
<!-- These rules are a union of the wikipedia and ITU document prefixes. They are mostly
1447714487
marked as VoIP on wikipedia, but it seems they may indeed be DID (Direct Inward

0 commit comments

Comments
 (0)