Skip to content

rakeshbhat9/pypi-package-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

pypi-package-stats

Github actions repo to collect pypi stats. Inspired by Simon's repo https://github.com/simonw/package-stats

Below is workflow yaml with comments on each section.

name: Get latest package stats from pypi

# Cron to run workflow/job on schedule.
on:
  workflow_dispatch:
  schedule:
    - cron: '0 9 * * 1'

jobs:
  scheduled:
    runs-on: ubuntu-latest
    
    steps:
    # First step is to check out the repo.
    - name: Check out repo
      uses: actions/checkout@v2
      
      # Next we curl stats from api which returns json. Replace yahoo-finance-api with package of choice.
    - name: Get latest PyPI stats
      run: |
        curl "https://pypistats.org/api/packages/yahoo-finance-api/overall?mirrors=true" > stats.json
      
      # Next below uses jq to parse json and sum total number of downloads.
    - name: Sum total downloads
      run: |
        cat stats.json | jq '[.data[] .downloads] | add' > total_count.txt 
      
      # Finally workflow checks if files have changed post above steps, if true then new files are committed to the repo with timestamp, else pass.
      # I've picked this bit from Simon's repo without much deep dive.
    - name: Commit and push if s changed
      run: |-
        git config user.name "Automated"
        git config user.email "actions@users.noreply.github.com"
        git add -A
        timestamp=$(date -u)
        git commit -m "Latest data: ${timestamp}" || exit 0
        git push ```

About

Github actions repo to collect pypi stats. Inspired by Simon's repo https://github.com/simonw/package-stats

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published