2021-08-24 04:19:24 +00:00
|
|
|
#!/usr/bin/python3
|
CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
#
|
|
|
|
# Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
# https://developers.google.com/open-source/licenses/bsd
|
|
|
|
"""This script extracts a version or release notes from the changelog."""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
|
|
parser.add_argument('--release_notes', action='store_true',
|
|
|
|
help='Print the latest release notes from the changelog')
|
|
|
|
parser.add_argument('--version', action='store_true',
|
|
|
|
help='Print the latest version from the changelog')
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2021-08-24 04:19:24 +00:00
|
|
|
with open('CHANGELOG.md', 'r', encoding='utf8') as f:
|
CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
contents = f.read()
|
|
|
|
|
|
|
|
# This excludes the header line with the release name and date, to match the
|
|
|
|
# style of releases done before the automation was introduced.
|
|
|
|
latest_entry = re.split(r'^(?=## \[)', contents, flags=re.M)[1]
|
|
|
|
|
|
|
|
lines = latest_entry.strip().split('\n')
|
|
|
|
first_line = lines[0]
|
|
|
|
release_notes = '\n'.join(lines[1:])
|
|
|
|
|
|
|
|
match = re.match(r'^## \[(.*)\]', first_line)
|
|
|
|
if not match:
|
|
|
|
raise RuntimeError('Unable to parse first line of CHANGELOG.md!')
|
|
|
|
|
|
|
|
version = match[1]
|
|
|
|
if not version.startswith('v'):
|
|
|
|
version = 'v' + version
|
|
|
|
|
|
|
|
if args.version:
|
|
|
|
print(version)
|
|
|
|
if args.release_notes:
|
|
|
|
print(release_notes)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|