forked from twisted/twisted
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
246 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# | ||
# This handles the automated release process. | ||
# | ||
# It is also triggered for pull-request to rehearse the release process | ||
# as often as possible. | ||
# | ||
# It handles the release packages publishing on PyPi via a token stored on | ||
# GitHub Secrets. | ||
# | ||
# The Read The Docs documentation is generated and publish as part of the | ||
# RTD build system. It isn't done in GitHub Actions. | ||
# | ||
# The default RTD version is updated based on an RTD token stored on | ||
# GitHub Secrets. | ||
# | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ trunk ] | ||
tags: | ||
- twisted-* | ||
pull_request: | ||
branches: [ trunk ] | ||
|
||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
|
||
jobs: | ||
|
||
pypi: | ||
name: Check release and publish on twisted-* tag | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Test | ||
run: | | ||
python -m pip install --upgrade pip tox pep517 | ||
rm -rf dist/* | ||
tox -e release-prepare | ||
- uses: twisted/python-info-action@v1 | ||
|
||
- name: Display structure of files to be pushed | ||
run: ls -R dist/ | ||
|
||
- name: Check matched tag version and branch version - on tag | ||
if: startsWith(github.ref, 'refs/tags/twisted-') | ||
run: python admin/check_tag_version_match.py "${{ github.ref }}" | ||
|
||
- name: Publish to PyPI - on tag | ||
if: startsWith(github.ref, 'refs/tags/twisted-') | ||
uses: pypa/gh-action-pypi-publish@v1.3.1 | ||
with: | ||
password: ${{ secrets.PYPI_UPLOAD_TOKEN }} | ||
|
||
|
||
# This is a simple API call to wait for the release documentation | ||
# to be available on RTD and update the default version. | ||
rtd: | ||
name: Read the Docs default version update | ||
if: startsWith(github.ref, 'refs/tags/twisted-') | ||
runs-on: ubuntu-20.04 | ||
env: | ||
RTD_PAT: ${{ secrets.RTD_PAT_ADI }} | ||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get intall -fy curl | ||
# The RTD build is done in parallel with GHA. | ||
# Wait as by the time this step is executed the RTD build might not be done. | ||
- name: Wait for version build to be available | ||
run: | | ||
TAG_NAME=${GITHUB_REF#refs/tags/} | ||
echo $TAG_NAME | ||
./admin/wait-for-cmd.sh -g $TAG_NAME -t 900 -- curl -H "Authorization: Token $RTD_PAT" https://readthedocs.org/api/v3/projects/twisted/versions/ | ||
- name: Update RTD default version - on tag | ||
run: | | ||
TAG_NAME=${GITHUB_REF#refs/tags/} | ||
echo $TAG_NAME | ||
cat > rtd-request-body.json | ||
{ | ||
"default_version": "$TAG_NAME", | ||
} | ||
END | ||
curl \ | ||
-X PATCH \ | ||
-H "Authorization: Token $RTD_PAT" \ | ||
-H "Content-Type: application/json" \ | ||
-d @rtd-request-body.json \ | ||
https://readthedocs.org/api/v3/projects/twisted/ |
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,139 @@ | ||
#!/usr/bin/env bash | ||
# Use this script to test if a given command produces an expected output. | ||
# | ||
# Based on | ||
# Source https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh | ||
# | ||
WAITFORIT_cmdname=${0##*/} | ||
|
||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } | ||
|
||
usage() | ||
{ | ||
exit_code=$1 | ||
cat << USAGE >&2 | ||
Usage: | ||
$WAITFORIT_cmdname [-g VALUE] [-s] [-t timeout] [-- command args] | ||
-g VALUE | --grep=VALUE Grep the command output. | ||
-q | --quiet Don't output any status messages | ||
-h | --help This help message | ||
-t TIMEOUT | --timeout=TIMEOUT | ||
Timeout in seconds, zero for no timeout | ||
-- COMMAND ARGS Execute command with args until exit code is 0 | ||
USAGE | ||
exit $exit_code | ||
} | ||
|
||
wait_for() | ||
{ | ||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then | ||
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for '$WAITFORIT_CLI' to produce '$WAITFORIT_VALUE'" | ||
else | ||
echoerr "$WAITFORIT_cmdname: waiting for '$WAITFORIT_CLI' to produce '$WAITFORIT_VALUE' without a timeout" | ||
fi | ||
WAITFORIT_start_ts=$(date +%s) | ||
while : | ||
do | ||
if [[ "$WAITFORIT_VALUE" == "" ]]; then | ||
$WAITFORIT_CLI | ||
else | ||
$WAITFORIT_CLI | grep $WAITFORIT_VALUE | ||
fi | ||
WAITFORIT_result=$? | ||
|
||
if [[ $WAITFORIT_result -eq 0 ]]; then | ||
WAITFORIT_end_ts=$(date +%s) | ||
echoerr "$WAITFORIT_cmdname: $WAITFORIT_CLI is present after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
return $WAITFORIT_result | ||
} | ||
|
||
wait_for_wrapper() | ||
{ | ||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 | ||
if [[ $WAITFORIT_QUIET -eq 1 ]]; then | ||
timeout $WAITFORIT_TIMEOUT $0 --child --quiet --grep=$WAITFORIT_VALUE --timeout=$WAITFORIT_TIMEOUT -- "$WAITFORIT_CLI" & | ||
else | ||
timeout $WAITFORIT_TIMEOUT $0 --child --grep=$WAITFORIT_VALUE --timeout=$WAITFORIT_TIMEOUT -- "$WAITFORIT_CLI" & | ||
fi | ||
WAITFORIT_PID=$! | ||
trap "kill -INT -$WAITFORIT_PID" INT | ||
wait $WAITFORIT_PID | ||
WAITFORIT_RESULT=$? | ||
if [[ $WAITFORIT_RESULT -ne 0 ]]; then | ||
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_CLI" | ||
fi | ||
return $WAITFORIT_RESULT | ||
} | ||
|
||
# process arguments | ||
while [[ $# -gt 0 ]] | ||
do | ||
case "$1" in | ||
--child) | ||
WAITFORIT_CHILD=1 | ||
shift 1 | ||
;; | ||
-g) | ||
WAITFORIT_VALUE="$2" | ||
if [[ $WAITFORIT_VALUE == "" ]]; then break; fi | ||
shift 2 | ||
;; | ||
--grep=*) | ||
WAITFORIT_VALUE="${1#*=}" | ||
shift 1 | ||
;; | ||
-h) | ||
usage | ||
;; | ||
-t) | ||
WAITFORIT_TIMEOUT="$2" | ||
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi | ||
shift 2 | ||
;; | ||
--timeout=*) | ||
WAITFORIT_TIMEOUT="${1#*=}" | ||
shift 1 | ||
;; | ||
--) | ||
shift | ||
WAITFORIT_CLI="$@" | ||
break | ||
;; | ||
--help) | ||
usage | ||
;; | ||
*) | ||
echoerr "Unknown argument: $1" | ||
usage 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ "$WAITFORIT_CLI" == "" ]]; then | ||
echoerr "Error: you need to provide a command to test." | ||
usage 1 | ||
fi | ||
|
||
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} | ||
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} | ||
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} | ||
|
||
if [[ $WAITFORIT_CHILD -gt 0 ]]; then | ||
wait_for | ||
WAITFORIT_RESULT=$? | ||
exit $WAITFORIT_RESULT | ||
else | ||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then | ||
wait_for_wrapper | ||
WAITFORIT_RESULT=$? | ||
else | ||
wait_for | ||
WAITFORIT_RESULT=$? | ||
fi | ||
fi | ||
|
||
exit $WAITFORIT_RESULT |
Empty file.