From 44aa61168c0eaa0397c76ca74adc815159b5c45b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 11 Mar 2022 01:27:57 +0000 Subject: [PATCH] workflows: Add GitHub action for automating some release tasks For each release tag, this action will create a new release on GitHub, and for each -final tag, this action will build the documentation and upload it to GitHub. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D99780 --- .github/workflows/release-tasks.yml | 62 +++++++++++++++++++++ llvm/utils/release/github-upload-release.py | 26 ++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release-tasks.yml diff --git a/.github/workflows/release-tasks.yml b/.github/workflows/release-tasks.yml new file mode 100644 index 00000000000000..8a0f837af50c45 --- /dev/null +++ b/.github/workflows/release-tasks.yml @@ -0,0 +1,62 @@ +name: Release Task + +on: + push: + tags: + # The regex support here is limited, so just match everything that starts with llvmorg- and filter later. + - 'llvmorg-*' + +jobs: + release-tasks: + runs-on: ubuntu-latest + steps: + + - name: Install Dependencies + run: | + sudo apt-get install doxygen python3-sphinx python3-recommonmark ninja-build graphviz texlive-font-utils python3-github + pip3 install --user sphinx-markdown-tables + + - name: Checkout LLVM + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + # This step will only succeed if the tag name is valid, so it safe to + # assume a valid tag name in all steps after this one. + - name: Create Release + run: | + ./llvm/utils/release/./github-upload-release.py --token ${{ github.token }} --tag ${{ github.ref_name }} create + + - name: Get Release Name + id: release + run: | + name=`echo "${{ github.ref_name }}" | sed 's/llvmorg-//g'` + echo "::set-output name=name::$name" + + - name: Build Documentation + env: + RELEASE: "${{ steps.release.output.name }}" + run: | + bash llvm/utils/release/build-docs.sh -srcdir llvm -release $RELEASE + ./llvm/utils/release/./github-upload-release.py --token ${{ github.token }} --release $RELEASE upload --files *doxygen*.tar.xz + + - name: Clone www-releases + if: ${{ !contains(steps.release.outputs.name, 'rc') }} + uses: actions/checkout@v1 + with: + repository: ${{ github.repository_owner }}/www-releases + ref: main + fetch-depth: 0 + path: www-releases + + - name: Upload Release Notes + env: + RELEASE: "${{ steps.release.output.name }}" + run: | + ./github-automation.py --token ${{ github.token }} setup-llvmbot-git + mkdir -p ../www-releases/$RELEASE + mv ./docs-build/html-export/* ../www-releases/$RELEASE + cd ../www-releases + git add $RELEASE + git commit -a -m "Add $RELEASE documentation" + git push https://${{ secrets.WWW_RELEASES_TOKEN }}@github.com/${{ github.repository_owner }}/www-releases main:main diff --git a/llvm/utils/release/github-upload-release.py b/llvm/utils/release/github-upload-release.py index f0570a9e99ce68..ebaa7d657e8e15 100755 --- a/llvm/utils/release/github-upload-release.py +++ b/llvm/utils/release/github-upload-release.py @@ -30,6 +30,13 @@ import argparse import github +import re + +def tag_to_release(tag): + m = re.match("^llvmorg-([0-9]+\.[0-9]+\.[0-9]+)(-rc[0-9]+)?$", tag) + if not m: + raise Exception("Invalid tag: {}".format(tag)) + return "".join(m.groups("")) def create_release(repo, release, tag = None, name = None, message = None): if not tag: @@ -52,7 +59,6 @@ def upload_files(repo, release, files): print('Uploading {}'.format(f)) release.upload_asset(f) print("Done") - parser = argparse.ArgumentParser() @@ -61,6 +67,7 @@ def upload_files(repo, release, files): # All args parser.add_argument('--token', type=str) parser.add_argument('--release', type=str) +parser.add_argument('--tag', type=str) # Upload args parser.add_argument('--files', nargs='+', type=str) @@ -71,7 +78,20 @@ def upload_files(repo, release, files): github = github.Github(args.token) llvm_repo = github.get_organization('llvm').get_repo('llvm-project') +if args.tag and args.release: + print("--tag and --release are not allowed together") + sys.exit(1) + +if not args.tag and not args.release: + print("Must specify either --tag or --release") + sys.exit(1) + +if args.release: + release = args.release +else: + release = tag_to_release(args.tag) + if args.command == 'create': - create_release(llvm_repo, args.release) + create_release(llvm_repo, release, tag = args.tag) if args.command == 'upload': - upload_files(llvm_repo, args.release, args.files) + upload_files(llvm_repo, release, args.files)