Unverified Commit 9c95c4d7 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

CI to update JSON when releases are published (#178)

parent 7e0eefe8
name: Arduino-Pico Release Publisher
on:
release:
types: [published]
jobs:
package:
name: Update master JSON file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Deploy updated JSON
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
BUILD_TYPE: package
CI_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG=$(git describe --exact-match --tags)
curl -L -o ./package_rp2040_index.json "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$TAG/package_rp2040_index.json"
./package/update_release.py --token ${CI_GITHUB_API_KEY} --repo "$GITHUB_REPOSITORY" --tag global ./package_rp2040_index.json
......@@ -38,4 +38,4 @@ jobs:
log=$(find ./package/versions -name package_rp2040_index.log)
zip=$(find ./package/versions -name rp2040*zip)
tag=$(find ./package/versions -name package_rp2040_index.tag -exec cat \{\} \;)
python3 ./package/upload_release.py --user "$GITHUB_ACTOR" --repo "$GITHUB_REPOSITORY" --token "$CI_GITHUB_API_KEY" --tag "$tag" --name "Release $tag" --msg "@$log" "$zip" "$json"
python3 ./package/upload_release.py --repo "$GITHUB_REPOSITORY" --token "$CI_GITHUB_API_KEY" --tag "$tag" --name "Release $tag" --msg "@$log" "$zip" "$json"
#!/usr/bin/env python3
from github import Github
import argparse
parser = argparse.ArgumentParser(description='Refresh a set of files in an existing release')
parser.add_argument('--token', help="Github Personal Access Token (PAT)", type=str, required=True)
parser.add_argument('--repo', help="Repository", type=str, required=True)
parser.add_argument('--tag', help="Release tag", type=str, required=True)
parser.add_argument('files', nargs=argparse.REMAINDER)
args = parser.parse_args()
if len(args.files) == 0:
print("ERROR: No files specified")
quit()
gh = Github(login_or_token=args.token)
repo = gh.get_repo(str(args.repo))
for fn in args.files:
release = repo.get_release(args.tag)
for asset in release.get_assets():
if asset.name == fn:
print("Found '" + fn + "', updating")
asset.delete_asset()
release.upload_asset(fn)
......@@ -2,10 +2,8 @@
from github import Github
import argparse
import re
parser = argparse.ArgumentParser(description='Upload a set of files to a new draft release')
parser.add_argument('--user', help="Github username", type=str, required=True)
parser.add_argument('--token', help="Github Personal Access Token (PAT)", type=str, required=True)
parser.add_argument('--repo', help="Repository", type=str, required=True)
parser.add_argument('--tag', help="Release tag", type=str, required=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment