Skip to content

Commit

Permalink
workflows: Add GitHub action for automating some release tasks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tstellar committed Mar 11, 2022
1 parent e618eb8 commit 44aa611
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 3 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/release-tasks.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 23 additions & 3 deletions llvm/utils/release/github-upload-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -52,7 +59,6 @@ def upload_files(repo, release, files):
print('Uploading {}'.format(f))
release.upload_asset(f)
print("Done")



parser = argparse.ArgumentParser()
Expand All @@ -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)
Expand All @@ -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)

0 comments on commit 44aa611

Please sign in to comment.