-
Notifications
You must be signed in to change notification settings - Fork 16
140 lines (122 loc) · 4.54 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Generate sing-box routing rules
on:
workflow_dispatch:
inputs:
PRE_RELEASE:
description: "Set as pre-release"
required: false
type: boolean
default: false
schedule:
- cron: "50 4 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Iran-sing-box-rules repository
uses: actions/checkout@v4
- name: Checkout sing-geoip repository
uses: actions/checkout@v4
with:
repository: Chocolate4U/sing-geoip
path: sing-geoip
- name: Checkout sing-geosite repository
uses: actions/checkout@v4
with:
repository: Chocolate4U/sing-geosite
path: sing-geosite
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache-dependency-path: sing-geoip/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 +'%A %F %T %Z')" >> $GITHUB_ENV
- name: Create release and rule-set directories
run: mkdir release rule-set
- name: Generate geoip.db file
run: |
cd sing-geoip
mkdir rule-set
go run -v .
mv *.db ../release
cp -a rule-set/. ../rule-set
- name: Generate geosite.db file
run: |
cd sing-geosite
mkdir rule-set
go run -v .
mv *.db ../release
cp -a rule-set/. ../rule-set
- name: Generate sha256sum
run: |
sha256sum release/geoip.db > release/geoip.db.sha256sum
sha256sum release/geoip-lite.db > release/geoip-lite.db.sha256sum
sha256sum release/geosite.db > release/geosite.db.sha256sum
sha256sum release/geosite-lite.db > release/geosite-lite.db.sha256sum
sha256sum release/security-ip.db > release/security-ip.db.sha256sum
sha256sum release/security.db > release/security.db.sha256sum
sha256sum release/geoip-services.db > release/geoip-services.db.sha256sum
- name: Generate Release Notes
run: |
echo "* Updated on ${{ env.RELEASE_DATE }}" > RELEASE_NOTES
- name: Push assets to release branch
if: ${{ !inputs.PRE_RELEASE }}
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: Push rule sets to rule-set branch
if: ${{ !inputs.PRE_RELEASE }}
run: |
cd rule-set || 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 rule-set
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 rule-set
- name: Purge jsDelivr CDN cache - release
if: ${{ !inputs.PRE_RELEASE }}
run: |
cd release || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done
- name: Purge jsDelivr CDN cache - rule-set
if: ${{ !inputs.PRE_RELEASE }}
run: |
cd rule-set || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@rule-set/${file}"
done
- name: Release and upload assets
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
body_path: RELEASE_NOTES
draft: false
prerelease: ${{ inputs.PRE_RELEASE }}
files: ./release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean older releases
if: ${{ !inputs.PRE_RELEASE }}
uses: dev-drprasad/[email protected]
with:
keep_latest: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}