diff --git a/.github/release-branch.sh b/.github/release-branch.sh new file mode 100755 index 0000000..9db93d3 --- /dev/null +++ b/.github/release-branch.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e -o pipefail + +mkdir -p release +cd release +git init +git config --local user.email "github-action@users.noreply.github.com" +git config --local user.name "GitHub Action" +git remote add origin https://github-action:$GITHUB_TOKEN@github.com/SagerNet/sing-geoip.git +git branch -M release +cp ../*.db ../*.sha256sum . +git add . +git commit -m "Update release" +git push -f origin release diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7141ecd..21df569 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,9 +32,15 @@ jobs: if: steps.build.outputs.skip != 'true' run: | sha256sum geoip.db > geoip.db.sha256sum + sha256sum geoip-cn.db > geoip-cn.db.sha256sum + - name: Release release branch + if: steps.build.outputs.skip != 'true' + run: .github/release-branch.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: dev-drprasad/delete-older-releases@v0.3.2 with: - keep_latest: 10 + keep_latest: 3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Release geoip @@ -44,4 +50,6 @@ jobs: tag_name: ${{ steps.build.outputs.tag }} files: | geoip.db - geoip.db.sha256sum \ No newline at end of file + geoip.db.sha256sum + geoip-cn.db + geoip-cn.db.sha256sum \ No newline at end of file diff --git a/.gitignore b/.gitignore index 236a20b..026e869 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /*.db *.mmdb /rule-set/ +/release/ \ No newline at end of file diff --git a/go.mod b/go.mod index 35fb537..38ad905 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/maxmind/mmdbwriter v1.0.0 github.com/oschwald/geoip2-golang v1.9.0 github.com/oschwald/maxminddb-golang v1.12.0 - github.com/sagernet/sing v0.2.18-0.20231129075305-eb56a60214be - github.com/sagernet/sing-box v1.6.8-0.20231129123339-5a56487cf544 + github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226 + github.com/sagernet/sing-box v1.8.0-beta.3 ) require ( @@ -17,10 +17,10 @@ require ( github.com/logrusorgru/aurora v2.0.3+incompatible // indirect github.com/miekg/dns v1.1.57 // indirect github.com/sagernet/sing-dns v0.1.11 // indirect - go4.org/netipx v0.0.0-20230824141953-6213f710f925 // indirect - golang.org/x/crypto v0.15.0 // indirect + go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect + golang.org/x/crypto v0.16.0 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/tools v0.15.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/tools v0.16.0 // indirect ) diff --git a/go.sum b/go.sum index d83a6fc..c35307a 100644 --- a/go.sum +++ b/go.sum @@ -17,25 +17,25 @@ github.com/oschwald/geoip2-golang v1.9.0/go.mod h1:BHK6TvDyATVQhKNbQBdrj9eAvuwOM github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs= github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/sagernet/sing v0.2.18-0.20231129075305-eb56a60214be h1:FigAM9kq7RRXmHvgn8w2a8tqCY5CMV5GIk0id84dI0o= -github.com/sagernet/sing v0.2.18-0.20231129075305-eb56a60214be/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= -github.com/sagernet/sing-box v1.6.8-0.20231129123339-5a56487cf544 h1:kHe9kQpKMEmGJbTdDntXA0rl1BdQWQZtkDaxmZkAPC4= -github.com/sagernet/sing-box v1.6.8-0.20231129123339-5a56487cf544/go.mod h1:C5Gcyr9BsHs1Iq7eAY53hAlh/j+5fjJVsLA18z/7ZL4= +github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226 h1:rcII71ho6F/7Nyx7n2kESLcnvNMdcU4i8ZUGF2Fi7yA= +github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80= +github.com/sagernet/sing-box v1.8.0-beta.3 h1:2uotZm8GQrx6lztuHzdmHR4Fk/FV6G7eETWmcTmCWi8= +github.com/sagernet/sing-box v1.8.0-beta.3/go.mod h1:WOnlC8xcuQDYvkSXi0k6Szfqn5CXSV2nmQzCIiZ/nRI= github.com/sagernet/sing-dns v0.1.11 h1:PPrMCVVrAeR3f5X23I+cmvacXJ+kzuyAsBiWyUKhGSE= github.com/sagernet/sing-dns v0.1.11/go.mod h1:zJ/YjnYB61SYE+ubMcMqVdpaSvsyQ2iShQGO3vuLvvE= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -go4.org/netipx v0.0.0-20230824141953-6213f710f925 h1:eeQDDVKFkx0g4Hyy8pHgmZaK0EqB4SD6rvKbUdN3ziQ= -go4.org/netipx v0.0.0-20230824141953-6213f710f925/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= +go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= -golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/main.go b/main.go index 0b0fdcd..6078061 100644 --- a/main.go +++ b/main.go @@ -10,18 +10,19 @@ import ( "sort" "strings" - "github.com/google/go-github/v45/github" - "github.com/maxmind/mmdbwriter" - "github.com/maxmind/mmdbwriter/inserter" - "github.com/maxmind/mmdbwriter/mmdbtype" - "github.com/oschwald/geoip2-golang" - "github.com/oschwald/maxminddb-golang" "github.com/sagernet/sing-box/common/srs" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" E "github.com/sagernet/sing/common/exceptions" + + "github.com/google/go-github/v45/github" + "github.com/maxmind/mmdbwriter" + "github.com/maxmind/mmdbwriter/inserter" + "github.com/maxmind/mmdbwriter/mmdbtype" + "github.com/oschwald/geoip2-golang" + "github.com/oschwald/maxminddb-golang" ) var githubClient *github.Client @@ -189,6 +190,7 @@ func release(source string, destination string, output string, ruleSetOutput str for code := range countryMap { allCodes = append(allCodes, code) } + writer, err := newWriter(metadata, allCodes) if err != nil { return err @@ -198,6 +200,15 @@ func release(source string, destination string, output string, ruleSetOutput str return err } + writer, err = newWriter(metadata, []string{"cn"}) + if err != nil { + return err + } + err = write(writer, countryMap, "geoip-cn.db", []string{"cn"}) + if err != nil { + return err + } + os.RemoveAll(ruleSetOutput) err = os.MkdirAll(ruleSetOutput, 0o755) if err != nil { @@ -229,6 +240,7 @@ func release(source string, destination string, output string, ruleSetOutput str } outputRuleSet.Close() } + setActionOutput("tag", *sourceRelease.Name) return nil }