-
Notifications
You must be signed in to change notification settings - Fork 698
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
Jash Parekh
committed
Apr 17, 2021
1 parent
c99c8d4
commit c5602f5
Showing
41 changed files
with
1,508 additions
and
609 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,8 @@ | ||
set -euo pipefail | ||
|
||
echo "Ensuring pip is up to date" | ||
python -m pip install --upgrade pip | ||
echo "Installing the latest version of pypa/build" | ||
pip install build | ||
|
||
python -m build --sdist --wheel --outdir dist/ . |
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,8 @@ | ||
name: "Build Python package" | ||
description: "Build a wheel and sdist for the package" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Build wheel" | ||
run: "$GITHUB_ACTION_PATH/action.sh" | ||
shell: "bash" |
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,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
echo "::group::Configure Git User" | ||
"${GITHUB_ACTION_PATH}/configure_git_user.sh" | ||
echo "::endgroup::" | ||
|
||
echo "::group::Pull down latest docs commit" | ||
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin gh-pages | ||
echo "::endgroup::" | ||
|
||
echo "::group::Publish documentation" | ||
if [[ "${NEW_VERSION}" == "false" ]]; then | ||
if [[ "${VERSION_NAME}" == "" ]]; then | ||
echo "::error::'version_name' must be specified when 'NEW_VERSION' is false." | ||
exit 1 | ||
fi | ||
echo "mike deploy \"${VERSION_NAME}\"" | ||
mike deploy "${VERSION_NAME}" | ||
elif [[ "${GITHUB_EVENT_NAME:-}" != "release" ]]; then | ||
echo "::error::new_version can only be used for release events." | ||
exit 1 | ||
else | ||
# drop leading "v" from tag name to have just the version number | ||
"${GITHUB_ACTION_PATH}/update_docs_for_version.sh" "${RELEASE_TAG:1}" | ||
fi | ||
echo "git push origin gh-pages" | ||
git push origin gh-pages | ||
echo "::endgroup::" |
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,37 @@ | ||
name: "Publish Docs with Mike" | ||
description: | | ||
Publish versioned documentation with Mike. | ||
Requires a python environment to already be setup with mike and any other documentation dependencies installed. | ||
inputs: | ||
version_name: | ||
description: | | ||
Name a version to publish. | ||
Required when new_version is false. | ||
required: false | ||
default: "" | ||
new_version: | ||
description: | | ||
If true, publish a new docs version. If an existing version uses the alias/tile "latest", | ||
update the records so that the new version becomes the latest version. | ||
If version_name is given, that value will be used. Otherwise the release tag will be used. | ||
required: false | ||
default: "false" | ||
commit_user_name: | ||
description: "User name to use for commits. When omitted, the event values will be inspected to derive the name." | ||
default: "" | ||
required: false | ||
commit_user_email: | ||
description: "User email to use for commits. When omitted, the event values will be inspected to derive the email." | ||
default: "" | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: "$GITHUB_ACTION_PATH/action.sh" | ||
shell: "bash" | ||
env: | ||
USER_NAME: ${{ inputs.name }} | ||
USER_EMAIL: ${{ inputs.email }} | ||
VERSION_NAME: ${{ inputs.version_name }} | ||
NEW_VERSION: ${{ inputs.new_version }} | ||
RELEASE_TAG: ${{ github.event.release.tag_name }} |
45 changes: 45 additions & 0 deletions
45
.github/actions/publish-docs-with-mike/configure_git_user.sh
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,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
NO_REPLY_SUFFIX="@users.noreply.github.com" | ||
|
||
function set_and_exit() { | ||
local name="${USER_NAME:-$1}" | ||
local email="${USER_EMAIL:-$2}" | ||
git config --local user.name "${name}" | ||
git config --local user.email "${email}" | ||
exit 0 | ||
} | ||
|
||
function json_query() { | ||
jq -e "${1}" "${GITHUB_EVENT_PATH}" | ||
} | ||
|
||
if [[ "${USER_NAME}" != "" && "${USER_EMAIL}" != "" ]]; then | ||
set_and_exit | ||
fi | ||
|
||
echo "::debug::Attempting push event pusher" | ||
if json_query ".push.pusher" > /dev/null ; then | ||
echo "::debug::Found push event pusher" | ||
set_and_exit "$(json_query '.push.pusher.name')" "$(json_query '.push.pusher.email')" | ||
fi | ||
|
||
echo "::debug::Attempting merge merged by" | ||
if json_query ".pull_request.merged_by" > /dev/null ; then | ||
echo "::debug::Found pull request event merged by" | ||
LOGIN="$(json_query '.pull_request.merged_by.login')" | ||
set_and_exit "${LOGIN}" "${LOGIN}${NO_REPLY_SUFFIX}" | ||
fi | ||
|
||
echo "::debug::Attempting event sender" | ||
if json_query ".sender" > /dev/null ; then | ||
echo "::debug::Found pull event sender" | ||
LOGIN="$(json_query '.sender.login')" | ||
set_and_exit "${LOGIN}" "${LOGIN}${NO_REPLY_SUFFIX}" | ||
fi | ||
|
||
echo "::debug::Falling back to GITHUB_ACTOR" | ||
LOGIN="${GITHUB_ACTOR:-github_action}" | ||
set_and_exit "${LOGIN}" "${LOGIN}${NO_REPLY_SUFFIX}" |
15 changes: 15 additions & 0 deletions
15
.github/actions/publish-docs-with-mike/update_docs_for_version.sh
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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
NEW_VERSION="${1}" | ||
PREV_LATEST="$(mike list --json | jq --raw-output '.[] | select(.aliases == ["latest"]) | .version')" | ||
|
||
if [[ "${PREV_LATEST}" == "" ]]; then | ||
echo "No previous version found using the latest alias. Nothing to retitle." | ||
else | ||
echo "mike retitle --message \"Remove latest from title of ${PREV_LATEST}\" \"${PREV_LATEST}\" \"${PREV_LATEST}\"" | ||
mike retitle --message "Remove latest from title of ${PREV_LATEST}" "${PREV_LATEST}" "${PREV_LATEST}" | ||
fi | ||
echo "mike deploy --update-aliases --title \"${NEW_VERSION} (latest)\" \"${NEW_VERSION}\" \"latest\"" | ||
mike deploy --update-aliases --title "${NEW_VERSION} (latest)" "${NEW_VERSION}" "latest" |
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,19 @@ | ||
set -euo pipefail | ||
|
||
MODULE_NAME=$1 | ||
WHEEL_LOCATION=$2 | ||
|
||
echo "Ensuring pip is up to date" | ||
python -m pip install --upgrade pip | ||
|
||
APP_DIR=$(pwd) | ||
|
||
# move into root dir so Python will import the installed package instead of the local source files | ||
cd / | ||
echo "------------------" | ||
echo "Installing package" | ||
pip install ${APP_DIR}/${WHEEL_LOCATION}/*.whl | ||
|
||
echo "-----------------------------" | ||
echo "Attempting to import package" | ||
python "${GITHUB_ACTION_PATH}/test_module_import.py" "${MODULE_NAME}" |
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,16 @@ | ||
name: "Verify Python Wheel" | ||
description: "Verify importing the package doesn't cause an error" | ||
inputs: | ||
package-import-name: | ||
description: "Name used to import the package from python code" | ||
required: true | ||
packages-dir: | ||
description: The target directory for distribution | ||
required: false | ||
default: dist | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Verify wheel" | ||
run: "$GITHUB_ACTION_PATH/action.sh ${{ inputs.package-import-name }} ${{ inputs.packages-dir }}" | ||
shell: "bash" |
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,15 @@ | ||
import importlib | ||
import sys | ||
|
||
try: | ||
module_name = sys.argv[1] | ||
except IndexError: | ||
print("module_name must be provided as first argument to test_module_import.py script") | ||
sys.exit(1) | ||
|
||
try: | ||
module = importlib.import_module(module_name) | ||
except Exception as e: | ||
print(f"Error importing module {module_name}: {e}") | ||
sys.exit(1) | ||
print(f"Imported {module_name} version {module.__version__}") |
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
Oops, something went wrong.