diff --git a/.github/workflows/pkgs-delete.yml b/.github/workflows/pkgs-delete.yml index 1dd8eab74..a0ec38710 100644 --- a/.github/workflows/pkgs-delete.yml +++ b/.github/workflows/pkgs-delete.yml @@ -7,58 +7,6 @@ on: jobs: - delete-myget-big-pkgs: - name: Delete Big MyGet Packages - runs-on: ubuntu-latest - steps: - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install Requests - run: pip install requests - - name: Install Packaging - run: pip install packaging - - name: Delete versions below 3.6.1 - env: - MYGET_FEED: 'neo' - PACKAGE_NAMES: 'bctklib,Neo.Assertions,Neo.BuildTasks,Neo.Collector,Neo.Test.Harness,Neo.Test.Runner,Neo.Trace,Neo.WorkNet,Neo.Json' - MYGET_API_KEY: ${{ secrets.MYGET_TOKEN }} - run: | - import requests - from packaging import version - import os - - def get_versions(feed, package_name, api_key): - url = f"https://www.myget.org/F/{feed}/api/v2/Packages?$select=Version&$filter=Id eq '{package_name}'&$format=json" - headers = {'Accept': 'application/json'} - response = requests.get(url, headers=headers) - if response.status_code == 200: - versions = response.json()['d']['results'] - return [ver['Version'] for ver in versions] - else: - return [] - - def delete_version(feed, package_name, ver, api_key): - url = f"https://www.myget.org/F/{feed}/api/v2/package/{package_name}/{ver}?hardDelete=true" - headers = {"X-NuGet-ApiKey": api_key} - response = requests.delete(url, headers=headers) - return response.status_code == 200 # Success - - feed = os.environ['MYGET_FEED'] - package_names = os.environ['PACKAGE_NAMES'].split(',') - api_key = os.environ['MYGET_API_KEY'] - - for package_name in package_names: - versions_to_delete = get_versions(feed, package_name, api_key) - for ver in versions_to_delete: - if delete_version(feed, package_name, ver, api_key): - print(f"Deleted version {ver} of package {package_name}.") - else: - print(f"Failed to delete version {ver} of package {package_name}.") - - shell: python - delete-myget-pkgs: name: Delete Old MyGet Packages runs-on: ubuntu-latest