-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (154 loc) · 4.9 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Generate Release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sitemaps:
runs-on: ubuntu-20.04
name: Fetch Sitemaps
steps:
- name: Fetch Sitemap Index
run: |
wget \
--no-verbose \
--tries 3 \
--waitretry 10 \
--retry-on-http-error 500,503 \
--user-agent "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--output-document sitemapindex.xml \
'https://chromewebstore.google.com/sitemap'
- name: Extract Sitemap URLs
run: |
grep -F '<loc>' ./sitemapindex.xml |
awk -F '[<>]' '{ gsub(/&/, "\\&", $3); print $3 }' > sitemapindex.txt
- name: Fetch Sitemap Shards
run: |
sort --random-sort ./sitemapindex.txt |
grep -v "&hl=" |
parallel \
--max-procs 10 \
--max-replace-args 100 \
--pipe \
"wget \
--no-verbose \
--tries 3 \
--waitretry 10 \
--retry-on-http-error 500,503 \
--user-agent '${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}' \
--directory-prefix . \
--input-file -"
- name: Extract URLs
run: |
grep -F '<loc>' "sitemap?"* |
awk -F '[<>]' '{ gsub(/&/, "\\&", $3); print $3 }' > ./urls.txt
- name: Extract Extensions
run: |
awk -F/ '{ print substr($6, 0, 32) }' ./urls.txt | sort -u > ./extensions.txt
- name: Upload
uses: actions/upload-artifact@v4
with:
name: sitemaps
path: "*.txt"
if-no-files-found: error
retention-days: 1
details:
runs-on: ubuntu-20.04
needs: sitemaps
name: Fetch Details (${{matrix.prefix}})
strategy:
max-parallel: 16
matrix:
prefix: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Download URLs
uses: actions/download-artifact@v4
with:
name: sitemaps
path: sitemaps
- name: Fetch Details
run: |
awk -F'/' '$0 ~ /^${{matrix.prefix}}/ {
print "https://chrome.google.com/webstore/ajax/detail?pv=20210820&id=" $0
}' ./sitemaps/extensions.txt | parallel \
--max-procs 10 \
--max-replace-args 10000 \
--pipe \
"wget \
--no-verbose \
--tries 3 \
--waitretry 10 \
--retry-on-http-error 500,503 \
--user-agent '${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}' \
--output-document details.{#}.json \
--method POST \
--input-file -" || true
- name: Extract Details
run: |
python extract.py ${{matrix.prefix}}
- name: Upload Manifests
uses: actions/upload-artifact@v4
with:
name: "details-${{matrix.prefix}}"
path: "*.tar"
if-no-files-found: error
retention-days: 1
release:
runs-on: ubuntu-20.04
needs: details
name: Release
steps:
- name: Download Sitemaps
uses: actions/download-artifact@v4
with:
name: sitemaps
path: sitemaps
- name: Compress Sitemaps
working-directory: sitemaps
run: |
tar -cvjSf ../sitemaps.tar.bz2 .
- name: Download Manifest
uses: actions/download-artifact@v4
with:
path: details
pattern: details-*
merge-multiple: true
- name: Concatenate Manifests
run: |
ls -1 details/manifests-*.tar | xargs -n1 tar --concatenate --file manifests.tar
- name: Compress Manifests
run: |
bzip2 manifests.tar
- name: Concatenate Details
run: |
ls -1 details/details-*.tar | xargs -n1 tar --concatenate --file details.tar
- name: Compress Details
run: |
bzip2 details.tar
- name: Generate Tag
id: tag
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
gh release create \
--repo "$GITHUB_REPOSITORY" \
--title "${{ steps.tag.outputs.date }}" \
--notes "Action URL: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
"${{ steps.tag.outputs.date }}"
- name: Upload Artifacts
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
gh release upload \
--repo "$GITHUB_REPOSITORY" \
"${{ steps.tag.outputs.date }}" \
"sitemaps.tar.bz2" \
"manifests.tar.bz2" \
"details.tar.bz2"