-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically dispatch emscripten release tag action (#1442)
This PR add several features to release automation: 1. The existing tag-release job has an output that indicates whether the triggering commit is a release (i.e. whether it matches the regex) 2. The new followup job runs a new script which fetches the recent emscripten-releases revisions, reads the DEPS file from the 'latest' release in emscripten-releases-tags.json to find the corresponding emscripten revision and writes it into the environment 2. The final step reads the emscripten revision from the environment and creates a workflow_dispatch event to run the tag-release.yml job on the emscripten repo
- Loading branch information
Showing
3 changed files
with
115 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
EMSCRIPTEN_RELEASES_GIT = 'https://chromium.googlesource.com/emscripten-releases' | ||
TAGFILE = 'emscripten-releases-tags.json' | ||
|
||
def get_latest_hash(tagfile): | ||
with open(tagfile) as f: | ||
versions = json.load(f) | ||
latest = versions['aliases']['latest'] | ||
return versions['releases'][latest] | ||
|
||
def get_latest_emscripten(tagfile): | ||
latest = get_latest_hash(tagfile) | ||
if not os.path.isdir('emscripten-releases'): | ||
subprocess.run(['git', 'clone', EMSCRIPTEN_RELEASES_GIT, '--depth', | ||
'100'], check=True) | ||
# This will fail if the 'latest' revision is not within the most recent | ||
# 100 commits; but that shouldn't happen because this script is intended | ||
# to be run right after a release is added. | ||
info = subprocess.run(['emscripten-releases/src/release-info.py', | ||
'emscripten-releases', latest], | ||
stdout=subprocess.PIPE, check=True, text=True).stdout | ||
for line in info.split('\n'): | ||
tokens = line.split() | ||
if len(tokens) and tokens[0] == 'emscripten': | ||
return tokens[2] | ||
|
||
if __name__ == '__main__': | ||
emscripten_hash = get_latest_emscripten(TAGFILE) | ||
print('Emscripten revision ' + emscripten_hash) | ||
if 'GITHUB_ENV' in os.environ: | ||
with open(os.environ['GITHUB_ENV'], 'a') as f: | ||
f.write(f'EMSCRIPTEN_HASH={emscripten_hash}') | ||
sys.exit(0) | ||
print('Not a GitHub Action') | ||
sys.exit(1) |