-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (68 loc) · 2.47 KB
/
make-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
name: Daily CVE Processing and Release
on:
schedule:
- cron: '0 0 * * *' # Runs at midnight every day
workflow_dispatch: # Allows for manual triggering of the workflow
jobs:
download-process-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Download and process data
run: |
python sync.py
- name: Set environment variables for date
id: date
run: |
echo "TAG_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
echo "RELEASE_DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nvd-web-cves-${{ env.TAG_DATE }}
release_name: NVD Web CVEs ${{ env.RELEASE_DATE }}
body: "Automated daily release of processed CVE data."
draft: false
prerelease: false
- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag_name="nvd-web-cves-${{ env.TAG_DATE }}"
echo "Release ID: ${{ steps.create_release.outputs.id }}"
echo "Tag name: $tag_name"
for file in releases/*.json.xz; do
echo "Uploading $file"
gh release upload "$tag_name" "$file" --clobber || echo "Failed to upload $file"
done
- name: Remove old releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_date=$(date +%s)
gh release list --limit 100 | while read -r release; do
release_date=$(echo $release | awk '{print $NF}')
release_date_seconds=$(date -d $release_date +%s)
release_id=$(echo $release | awk '{print $1}')
release_age_days=$(( (current_date - release_date_seconds) / 86400 ))
if [ $release_age_days -gt 30 ]; then
echo "Deleting release $release_id (age: $release_age_days days)"
gh release delete $release_id --yes
fi
done