-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add version input variable (#27)
* feat: add version input variable Signed-off-by: Ludovic Ortega <[email protected]> * chore(docs): readme typo Signed-off-by: Ludovic Ortega <[email protected]> * fix: use bash script file instead of raw script * fix: variable interpolation * fix: GITHUB_TOKEN bash variable interpolation * fix: output version description * fix: VERSION variable interpolation * fix: add back "lastest" in version description * fix: add suggested changes Co-authored-by: Orhun Parmaksız <[email protected]> * refactor: polish implementation * chore: bump version --------- Signed-off-by: Ludovic Ortega <[email protected]> Co-authored-by: Orhun Parmaksız <[email protected]>
- Loading branch information
Showing
6 changed files
with
74 additions
and
43 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 was deleted.
Oops, something went wrong.
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 @@ | ||
#!/bin/bash | ||
|
||
set -uxo pipefail | ||
|
||
case "${RUNNER_OS}" in | ||
macOS) OS=apple-darwin ;; | ||
Windows) OS=pc-windows-msvc ;; | ||
*) OS=unknown-linux-gnu ;; | ||
esac | ||
case "${RUNNER_ARCH}" in | ||
ARM64) ARCH=aarch64 ;; | ||
ARM) ARCH=pc-windows-msvc ;; | ||
X86) ARCH=i686 ;; | ||
*) ARCH=x86_64 ;; | ||
esac | ||
|
||
RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest' | ||
if [[ "${VERSION}" != 'latest' ]]; then | ||
RELEASE_URL="https://api.github.com/repos/orhun/git-cliff/releases/tags/${VERSION}" | ||
fi | ||
|
||
# Although releases endpoint is available without authentication, the current github.token is still passed | ||
# in order to increase the limit of 60 requests per hour per IP address to a higher value that's also counted | ||
# per GitHub account. | ||
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API. | ||
RELEASE_INFO="$(curl --silent --show-error --fail \ | ||
--header "authorization: Bearer ${GITHUB_TOKEN}" \ | ||
--header 'Cache-Control: no-cache, must-revalidate' \ | ||
"${RELEASE_URL}")" | ||
TAG_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".tag_name")" | ||
TARGET="git-cliff-${TAG_NAME:1}-${ARCH}-${OS}.tar.gz" | ||
LOCATION="$(echo "${RELEASE_INFO}" \ | ||
| jq --raw-output ".assets[].browser_download_url" \ | ||
| grep "${TARGET}$")" | ||
|
||
# Skip downloading release if downloaded already, e.g. when the action is used multiple times. | ||
if [[ ! -e "$TARGET" ]]; then | ||
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION" | ||
tar -xf "$TARGET" | ||
mv git-cliff-${TAG_NAME:1}/git-cliff . | ||
fi |
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