Skip to content

Commit 83b9745

Browse files
Add GitHub action to automatically upgrade the metadata (#62)
* Fix generate files isoCodeImport * Add update meta data action * Test * Add checkout step * Update Metadata * Set real cron value --------- Co-authored-by: GitHub Actions <actions@github.com>
1 parent 875a2d4 commit 83b9745

10 files changed

+340
-176
lines changed

.github/workflows/update_metadata.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Update Metadata
2+
3+
on:
4+
schedule:
5+
# At 12:00 AM, on day 1 of each month
6+
- cron: "0 0 1 * *"
7+
8+
jobs:
9+
generate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: dart-lang/setup-dart@v1
15+
16+
- name: Install dependencies
17+
run: dart pub get
18+
19+
- name: Fetch LibPhoneNumber Metadata
20+
run: curl -o resources/data_sources/PhoneNumberMetadata.xml https://raw.githubusercontent.com/google/libphonenumber/master/resources/PhoneNumberMetadata.xml
21+
22+
- name: Process Metadata
23+
run: dart resources/data_sources/convert_metadata.dart
24+
25+
- name: Generate Files
26+
run: |
27+
dart pub get
28+
dart resources/generate_files.dart && dart format lib/src && dart fix --apply
29+
30+
- name: Commit and Push Updated Files
31+
run: |
32+
git config --global user.name "GitHub Actions"
33+
git config --global user.email "actions@github.com"
34+
git add .
35+
git commit -m "Update Metadata" || echo "Nothing to commit!"
36+
git push

lib/src/metadata/generated/metadata_by_iso_code.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ const metadataByIsoCode = {
600600
isoCode: IsoCode.GA,
601601
leadingDigits: null,
602602
internationalPrefix: r"00",
603-
nationalPrefix: null,
603+
nationalPrefix: r"0",
604604
isMainCountryForDialCode: false,
605605
),
606606
IsoCode.GB: PhoneMetadata(
@@ -1040,7 +1040,7 @@ const metadataByIsoCode = {
10401040
isoCode: IsoCode.LT,
10411041
leadingDigits: null,
10421042
internationalPrefix: r"00",
1043-
nationalPrefix: r"8",
1043+
nationalPrefix: r"0",
10441044
isMainCountryForDialCode: false,
10451045
),
10461046
IsoCode.LU: PhoneMetadata(

lib/src/metadata/generated/metadata_examples_by_iso_code.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ const metadataExamplesByIsoCode = {
289289
),
290290
IsoCode.DK: PhoneMetadataExamples(
291291
fixedLine: r"32123456",
292-
mobile: r"32123456",
292+
mobile: r"34412345",
293293
voip: r"",
294294
),
295295
IsoCode.DM: PhoneMetadataExamples(

lib/src/metadata/generated/metadata_formats_by_iso_code.dart

+24-6
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,17 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
10241024
)
10251025
],
10261026
IsoCode.CN: [
1027+
PhoneMetadataFormat(
1028+
pattern: r"(\d{5,6})",
1029+
nationalPrefixFormattingRule: null,
1030+
leadingDigits: [
1031+
"1(?:00|2[13])|95",
1032+
"1(?:00|2(?:11|39))|95",
1033+
"1(?:00|2(?:110|395))|95"
1034+
],
1035+
format: r"$1",
1036+
intlFormat: r"NA",
1037+
),
10271038
PhoneMetadataFormat(
10281039
pattern: r"(\d{5,6})",
10291040
nationalPrefixFormattingRule: null,
@@ -1719,7 +1730,7 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
17191730
IsoCode.GA: [
17201731
PhoneMetadataFormat(
17211732
pattern: r"(\d)(\d{2})(\d{2})(\d{2})",
1722-
nationalPrefixFormattingRule: r"0$FG",
1733+
nationalPrefixFormattingRule: r"$NP$FG",
17231734
leadingDigits: ["[2-7]"],
17241735
format: r"$1 $2 $3 $4",
17251736
intlFormat: null,
@@ -1733,8 +1744,8 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
17331744
),
17341745
PhoneMetadataFormat(
17351746
pattern: r"(\d{2})(\d{2})(\d{2})(\d{2})",
1736-
nationalPrefixFormattingRule: r"0$FG",
1737-
leadingDigits: ["11|[67]"],
1747+
nationalPrefixFormattingRule: r"$NP$FG",
1748+
leadingDigits: ["[167]"],
17381749
format: r"$1 $2 $3 $4",
17391750
intlFormat: null,
17401751
)
@@ -4604,7 +4615,7 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
46044615
PhoneMetadataFormat(
46054616
pattern: r"(\d{2})(\d{5})",
46064617
nationalPrefixFormattingRule: null,
4607-
leadingDigits: ["7|8[4-9]|9(?:[1-8]|9[0-8])"],
4618+
leadingDigits: ["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"],
46084619
format: r"$1 $2",
46094620
intlFormat: null,
46104621
)
@@ -5127,7 +5138,7 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
51275138
PhoneMetadataFormat(
51285139
pattern: r"(\d{2})(\d{6})",
51295140
nationalPrefixFormattingRule: r"$NP $FG",
5130-
leadingDigits: ["6"],
5141+
leadingDigits: ["[67]"],
51315142
format: r"$1 $2",
51325143
intlFormat: null,
51335144
)
@@ -5571,9 +5582,16 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
55715582
PhoneMetadataFormat(
55725583
pattern: r"(\d{3})(\d{3})(\d{3})",
55735584
nationalPrefixFormattingRule: r"$NP$FG",
5574-
leadingDigits: ["[23]"],
5585+
leadingDigits: ["2|39"],
55755586
format: r"$1 $2 $3",
55765587
intlFormat: null,
5588+
),
5589+
PhoneMetadataFormat(
5590+
pattern: r"(\d{2})(\d{7,10})",
5591+
nationalPrefixFormattingRule: r"$NP$FG",
5592+
leadingDigits: ["3"],
5593+
format: r"$1 $2",
5594+
intlFormat: null,
55775595
)
55785596
],
55795597
IsoCode.YE: [

lib/src/metadata/generated/metadata_lengths_by_iso_code.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ const metadataLenghtsByIsoCode = {
736736
),
737737
IsoCode.LA: PhoneMetadataLengths(
738738
general: [],
739-
mobile: [10],
739+
mobile: [9, 10],
740740
fixedLine: [8],
741741
voip: [],
742742
),
@@ -1439,7 +1439,7 @@ const metadataLenghtsByIsoCode = {
14391439
IsoCode.XK: PhoneMetadataLengths(
14401440
general: [],
14411441
mobile: [8],
1442-
fixedLine: [8, 9],
1442+
fixedLine: [8, 9, 10, 11, 12],
14431443
voip: [],
14441444
),
14451445
IsoCode.YE: PhoneMetadataLengths(

0 commit comments

Comments
 (0)