-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (129 loc) · 4.76 KB
/
run.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
# On every push this script is executed
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "0 3 * * *"
concurrency: data
name: Build data
jobs:
build-data:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Max build space
run: |
rm -rf /usr/share/dotnet/ &
rm -rf /usr/local/lib/android/ &
rm -rf /opt/ghc/ &
rm -rf /opt/hostedtoolcache/CodeQL/ &
sudo docker image prune --all --force &
df -h
- name: checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install deps
run: uv sync --frozen
- name: "Set current date as env variable"
run: |
echo "tag_name=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_OUTPUT
id: version
- name: Create Release
id: create-release
uses: shogo82148/actions-create-release@v1
with:
overwrite: true
draft: true
release_name: ${{ steps.version.outputs.tag_name }}
tag_name: ${{ steps.version.outputs.tag_name }}
commitish: ${{ github.sha }}
- name: Generate token
id: generate_token
uses: pypi-data/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
revoke: false
- name: Download hishel cache
uses: actions/cache/restore@v4
id: hisel-cache
with:
path: .hishel.sqlite
key: ${{ runner.os }}-hishel-${{ hashFiles('links/*.json') }}
- name: Generate Repo Metadata
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: uv run pypi-data load-repos repos-with-packages.jsonl.gz links/
- name: Upload hishel cache
uses: actions/cache/save@v4
if: steps.hisel-cache.outputs.cache-hit != 'true'
with:
path: .hishel.sqlite
key: ${{ steps.hisel-cache.outputs.cache-primary-key }}
- name: Upload Repos with packages
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/repos-with-packages.jsonl.gz
- name: Remove repos-with-packages.jsonl.gz
run: rm repos-with-packages.jsonl.gz
- name: Create dataset
run: uv run pypi-data merge-datasets links/repositories.json dataset/
- name: Debug
run: ls -la dataset/
- name: Upload Dataset
uses: shogo82148/actions-upload-release-asset@v1
id: upload-dataset
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/dataset/dataset-*.parquet
asset_content_type: application/vnd.apache.parquet
- name: Publish Draft Release
uses: actions/github-script@v7
with:
script: |
const releaseId = "${{ steps.create-release.outputs.id }}";
const response = await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
draft: false
});
if (response.status === 200) {
core.info(`Release ${releaseId} successfully published.`);
} else {
core.setFailed(`Failed to publish release ${releaseId}.`);
}
- name: Get download links
id: get_download_links
uses: actions/github-script@v7
with:
script: |
const response = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ steps.create-release.outputs.id }},
});
const assets = response.data;
const urls = assets.filter(asset => asset.name.endsWith(".parquet")).map(asset => asset.browser_download_url)
// Save the download links to a file
require('fs').writeFileSync('links/dataset.txt', urls.join('\n'));
const jsonUrls = assets.filter(asset => asset.name == "repos-with-packages.jsonl.gz").map(asset => asset.browser_download_url)
require('fs').writeFileSync('links/repositories-with-packages.txt', jsonUrls.join('\n'));
- uses: EndBug/add-and-commit@v9
with:
add: links/*
message: "Add repository URLs"
push: true
fetch: true
pull: '--rebase --autostash'