-
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
1 parent
2b8d7a5
commit 53b2ce5
Showing
4 changed files
with
131 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# .github/scripts/pushed_commit_range.sh | ||
# Retrieves the range of the commits in a push, and sets the PUSHED_COMMIT_RANGE environment variables. | ||
|
||
# GITHUB_CONTEXT: The github action context object as an environment variable. | ||
|
||
# CI only script | ||
|
||
set -eo pipefail | ||
|
||
|
||
get_all_commits() { | ||
git rev-list --max-parents=0 HEAD | ||
} | ||
|
||
|
||
main() { | ||
|
||
PUSHED_COMMIT_RANGE="HEAD~$(echo "$GITHUB_CONTEXT" | jq '.event.commits | length')" | ||
|
||
if [[ "${PUSHED_COMMIT_RANGE}" == "HEAD~0" ]]; then | ||
PUSHED_COMMIT_RANGE="$(get_all_commits)" | ||
fi | ||
|
||
set +e | ||
if ! git rev-parse "${PUSHED_COMMIT_RANGE}"; then | ||
PUSHED_COMMIT_RANGE="$(get_all_commits)" | ||
fi | ||
set -e | ||
|
||
{ | ||
echo "PUSHED_COMMIT_RANGE<<EOF" | ||
echo "${PUSHED_COMMIT_RANGE}" | ||
echo "EOF" | ||
} >> "$GITHUB_ENV" | ||
|
||
} | ||
|
||
main "$@" |
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,29 @@ | ||
#!/bin/bash | ||
|
||
# .github/scripts/upload_asset.sh | ||
# Upload an asset to a Github release. | ||
|
||
# FILE_PATH: The filename to upload. | ||
# GITHUB_TOKEN: The Github authentication token to use. | ||
# UPLOAD_URL: The release's upload url. | ||
|
||
# CI only script. | ||
|
||
set -eo pipefail | ||
|
||
main() { | ||
|
||
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/}" | ||
|
||
curl --fail -X POST \ | ||
-H "Content-Length: $(stat --format="%s" "${FILE_PATH}")" \ | ||
-H "Content-Type: $(file -b --mime-type "${FILE_PATH}")" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
-T "${FILE_PATH}" \ | ||
-H "Authorization: token ${GITHUB_TOKEN}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"${UPLOAD_URL}?name=$(basename "${FILE_PATH}")" | cat | ||
|
||
} | ||
|
||
main "$@" |
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