chore: Include tag information, if any in info.json (#25952)
This commit is contained in:
parent
e2343f5917
commit
e81c06359d
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,6 +3,7 @@
|
||||||
.env
|
.env
|
||||||
|
|
||||||
stacks
|
stacks
|
||||||
|
/info.json
|
||||||
|
|
||||||
# to ignore the node_modeules folder
|
# to ignore the node_modeules folder
|
||||||
node_modules
|
node_modules
|
||||||
|
|
@ -17,7 +18,6 @@ deploy/ansible/appsmith_playbook/inventory
|
||||||
# performance tests
|
# performance tests
|
||||||
app/client/perf/traces/*
|
app/client/perf/traces/*
|
||||||
.history
|
.history
|
||||||
stacks
|
|
||||||
|
|
||||||
# helm dependencies
|
# helm dependencies
|
||||||
deploy/helm/charts
|
deploy/helm/charts
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,40 @@ set -o nounset
|
||||||
|
|
||||||
commit_sha="$(git rev-parse HEAD)"
|
commit_sha="$(git rev-parse HEAD)"
|
||||||
|
|
||||||
|
# Base URL of the current repository on GitHub.
|
||||||
base_url="$(git remote get-url origin | sed 's,^git@github\.com:,https://github.com/,; s/\.git$//')"
|
base_url="$(git remote get-url origin | sed 's,^git@github\.com:,https://github.com/,; s/\.git$//')"
|
||||||
|
|
||||||
|
git_ref="${GITHUB_HEAD_REF-}"
|
||||||
|
if [[ -z "$git_ref" ]]; then
|
||||||
|
# If the GITHUB_HEAD_REF environment variable is not set, then we are not running in a GitHub Actions workflow.
|
||||||
|
# In that case, we will use the current branch name as the git ref.
|
||||||
|
git_ref="$(git symbolic-ref HEAD || echo)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Tag, if any, on the HEAD commit.
|
||||||
|
# Output of this `describe` command is described at https://git-scm.com/docs/git-describe#_examples.
|
||||||
|
git_tag="$(
|
||||||
|
# If HEAD is a commit in the `master` branch, then `git describe --tags` will give a relevant tag name.
|
||||||
|
if git merge-base --is-ancestor HEAD origin/master; then
|
||||||
|
git describe --tags --match 'v*' --dirty --broken | sed 's/-g.*$//'
|
||||||
|
fi
|
||||||
|
# This will look like `v1.9.30` when HEAD is the tag `v1.9.30`, or something like `v1.9.30-10` when HEAD is 10 commits
|
||||||
|
# ahead of the tag `v1.9.30`.
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [[ -n ${GITHUB_RUN_ID-} ]]; then
|
||||||
|
github_run_url="$base_url/actions/runs/$GITHUB_RUN_ID/attempts/${GITHUB_RUN_ATTEMPT-1}"
|
||||||
|
fi
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
--arg commitSha "$commit_sha" \
|
--arg commitSha "$commit_sha" \
|
||||||
--arg commitUrl "$base_url/commit/$commit_sha" \
|
--arg commitUrl "$base_url/commit/$commit_sha" \
|
||||||
--arg branch "$(git rev-parse --abbrev-ref HEAD)" \
|
--arg gitRef "$git_ref" \
|
||||||
|
--arg githubRef "$git_ref" \
|
||||||
|
--arg gitNearestTag "$git_tag" \
|
||||||
|
--arg githubRunUrl "${github_run_url-}" \
|
||||||
|
--arg gitUserName "$(git config user.name)" \
|
||||||
|
--arg gitUserEmail "$(git config user.email)" \
|
||||||
--arg date "$(date -u -Iseconds)" \
|
--arg date "$(date -u -Iseconds)" \
|
||||||
--argjson isCI "${CI:-false}" \
|
--argjson isCI "${CI:-false}" \
|
||||||
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/info.json"
|
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/info.json"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user