Skip to content

Commit d515149

Browse files
committed
update add iana repo
1 parent 0d39b15 commit d515149

File tree

2 files changed

+112
-3
lines changed

2 files changed

+112
-3
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build IANA Punched Dat
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
private_src_repo_slug:
7+
description: "Private source repository slug"
8+
required: true
9+
type: string
10+
private_src_ref:
11+
description: "Private source repository ref"
12+
required: false
13+
default: "main"
14+
type: string
15+
secrets:
16+
iana_private_repo_token:
17+
description: "Token for iana private repository checkout"
18+
required: true
19+
poptrie_private_repo_token:
20+
description: "Token for private repository checkout"
21+
required: true
22+
23+
defaults:
24+
run:
25+
shell: bash
26+
27+
jobs:
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout public repo
32+
uses: actions/checkout@v6
33+
34+
- name: Checkout private iana repo
35+
uses: actions/checkout@v6
36+
with:
37+
repository: harmonsir/iana-geoip
38+
token: ${{ secrets.iana_private_repo_token }}
39+
ref: main
40+
path: iana-src
41+
42+
- name: Checkout private repo
43+
uses: actions/checkout@v6
44+
with:
45+
repository: ${{ inputs.private_src_repo_slug }}
46+
token: ${{ secrets.poptrie_private_repo_token }}
47+
ref: ${{ inputs.private_src_ref }}
48+
path: private-src
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v6
52+
with:
53+
python-version: "3.13"
54+
55+
- name: Set up Rust toolchain
56+
uses: actions-rust-lang/setup-rust-toolchain@v1
57+
with:
58+
toolchain: stable
59+
60+
- name: Build punched iana-geoip.dat via Rust
61+
run: |
62+
set -euo pipefail
63+
mkdir -p "$GITHUB_WORKSPACE/dist"
64+
rm -rf iana-data
65+
git clone --depth 1 https://github.com/HotCakeX/Official-IANA-IP-blocks iana-data
66+
cargo build --release --manifest-path iana-src/Cargo.toml
67+
./iana-src/target/release/geoip_checker process \
68+
--ipv4-dir iana-data/TXT/IPV4 \
69+
--ipv6-dir iana-data/TXT/IPV6 \
70+
--output-dir iana-src/TXT
71+
./iana-src/target/release/geoip_checker check --output-dir iana-src/TXT
72+
python "$GITHUB_WORKSPACE/private-src/build_bin.py" \
73+
--input "$GITHUB_WORKSPACE/iana-src/TXT" \
74+
--output "$GITHUB_WORKSPACE/dist/iana-geoip.dat"
75+
76+
- name: Upload punched iana dat
77+
uses: actions/upload-artifact@v6
78+
with:
79+
name: iana-punched-dat
80+
path: dist/iana-geoip.dat
81+
retention-days: 3

.github/workflows/release.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ jobs:
5656
});
5757
}
5858
59+
build_iana_punched:
60+
if: github.event_name == 'push' || github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && (inputs.run_build == 'true' || inputs.run_cron == 'true'))
61+
uses: ./.github/workflows/build-iana-punched.yml
62+
with:
63+
private_src_repo_slug: ${{ vars.POPTRIE_PRIVATE_REPO_SLUG }}
64+
private_src_ref: ${{ vars.POPTRIE_PRIVATE_REPO_REF || 'main' }}
65+
secrets:
66+
iana_private_repo_token: ${{ secrets.HARMONSIR_IANA_GEOIP_REPO_TOKEN }}
67+
poptrie_private_repo_token: ${{ secrets.GH_POPTRIE_TOKEN }}
68+
5969
build:
6070
runs-on: ${{ matrix.os }}
6171
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.run_build == 'true')
@@ -154,7 +164,7 @@ jobs:
154164

155165
release:
156166
runs-on: ubuntu-latest
157-
needs: build
167+
needs: [ build, build_iana_punched ]
158168
permissions:
159169
contents: write
160170
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.run_build == 'true')
@@ -249,22 +259,32 @@ jobs:
249259
--iana-zip-url "https://github.com/HotCakeX/Official-IANA-IP-blocks/archive/refs/heads/main.zip" \
250260
--out-cn dist/geo-cn.dat \
251261
--out-geoip dist/bgp-geoip.dat \
252-
--out-iana dist/iana-geoip.dat
262+
--out-iana dist/iana-geoip-std.dat
263+
264+
- name: Download punched iana dat
265+
uses: actions/download-artifact@v7
266+
continue-on-error: false
267+
with:
268+
name: iana-punched-dat
269+
path: dist
253270

254271
- name: Publish latest release
255272
uses: softprops/action-gh-release@v2
256273
with:
257274
tag_name: latest
258275
name: latest
259276
generate_release_notes: true
277+
fail_on_unmatched_files: false
260278
files: |
261279
dist/*.whl
262280
dist/geo-cn.dat
263281
dist/bgp-geoip.dat
264282
dist/iana-geoip.dat
283+
dist/iana-geoip-std.dat
265284
266285
cron_release:
267286
runs-on: ubuntu-latest
287+
needs: build_iana_punched
268288
permissions:
269289
contents: write
270290
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.run_cron == 'true')
@@ -303,7 +323,14 @@ jobs:
303323
--iana-zip-url "https://github.com/HotCakeX/Official-IANA-IP-blocks/archive/refs/heads/main.zip" \
304324
--out-cn dist/geo-cn.dat \
305325
--out-geoip dist/bgp-geoip.dat \
306-
--out-iana dist/iana-geoip.dat
326+
--out-iana dist/iana-geoip-std.dat
327+
328+
- name: Download punched iana dat
329+
uses: actions/download-artifact@v7
330+
continue-on-error: false
331+
with:
332+
name: iana-punched-dat
333+
path: dist
307334

308335
- name: Set release tag
309336
run: echo "CRON_TAG=cron-$(date -u +%Y%m%d)" >> $GITHUB_ENV
@@ -313,6 +340,7 @@ jobs:
313340
with:
314341
tag_name: ${{ env.CRON_TAG }}
315342
name: ${{ env.CRON_TAG }}
343+
fail_on_unmatched_files: false
316344
files: |
317345
dist/geo-cn.dat
318346
dist/bgp-geoip.dat

0 commit comments

Comments
 (0)