-
Notifications
You must be signed in to change notification settings - Fork 8
119 lines (100 loc) · 3.96 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Generate v2ray routing rules
on:
workflow_dispatch:
schedule:
- cron: "0 1 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout ru-block-v2ray-rules repository
uses: actions/checkout@v4
- name: Checkout v2ray-geosite repository
uses: actions/checkout@v4
with:
repository: Nidelon/v2ray-geosite
path: v2ray-geosite
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache-dependency-path: v2ray-geosite/go.sum
- name: Set ENV variables
run: |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "RELEASE_DATE=$(date +'%F %T %Z')" >> $GITHUB_ENV
- name: Create release directory
run: mkdir release
- name: Get list of blocked IPs
run: |
curl -sSL https://antifilter.download/list/ip.lst -o ip-block-list.txt
echo "NUM_IP=$(wc -l < ip-block-list.txt)" >> $GITHUB_ENV
- name: Get a list of blocked domains
run: |
curl -sSL https://antifilter.download/list/domains.lst -o ru-block.txt
echo "NUM_DOMAIN=$(wc -l < ru-block.txt)" >> $GITHUB_ENV
- name: Generate geoip.dat and Country.mmdb files
run: |
go install -v github.com/Loyalsoldier/geoip@latest
$(go env GOPATH)/bin/geoip convert -c config.json
mv output/dat/geoip.dat release
mv output/maxmind/Country.mmdb release
# - name: Verify Country.mmdb files
# run: |
# go install -v github.com/maxmind/mmdbverify@latest
# $(go env GOPATH)/bin/mmdbverify -file release/Country.mmdb
- name: Generate geosite.dat file
run: |
cd v2ray-geosite
mkdir data
mv ../ru-block.txt data/ru-block
go run ./ --datapath=data --outputdir=../release --outputname=geosite.dat
- name: Generate sha256sum
run: |
sha256sum release/geoip.dat > release/geoip.dat.sha256sum
sha256sum release/Country.mmdb > release/Country.mmdb.sha256sum
sha256sum release/geosite.dat > release/geosite.dat.sha256sum
- name: Generate Release Notes
run: |
echo "* Обновлён ${{ env.RELEASE_DATE }}" > RELEASE_NOTES
echo "* Кол-во заблокированных доменов - ${{ env.NUM_DOMAIN }}" >> RELEASE_NOTES
echo "* Кол-во заблокированных IP адресов - ${{ env.NUM_IP }}" >> RELEASE_NOTES
- name: Push assets to release branch
run: |
cd release || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b release
git add .
git commit -m "${{ env.RELEASE_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f origin release
- name: Purge jsDelivr CDN cache
run: |
cd release || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done
- name: Release and upload assets
uses: softprops/action-gh-release@v1
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
body_path: RELEASE_NOTES
draft: false
prerelease: false
files: |
release/*.dat
release/*.mmdb
release/*.sha256sum
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean older releases
uses: dev-drprasad/delete-older-releases@v0.3.2
with:
keep_latest: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}