Skip to content

Commit

Permalink
Include branch name in version name in certain conditions.
Browse files Browse the repository at this point in the history
Resolve #705

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
  • Loading branch information
rgoldberg committed Jan 5, 2025
1 parent a5a928a commit b7964ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ jobs:
build-mode: manual
steps:
- name: Checkout repository
env:
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: init.defaultBranch
GIT_CONFIG_VALUE_0: ${{github.event.repository.default_branch}}
uses: actions/checkout@v4
with:
# Include all history & tags for script/version
fetch-depth: 0

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tag-pushed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
GIT_CONFIG_KEY_0: init.defaultBranch
GIT_CONFIG_VALUE_0: ${{github.event.repository.default_branch}}
uses: actions/checkout@v4
with:
# Include all history & tags for script/version
fetch-depth: 0

- name: 🖋 Delete tag lacking valid signature
run: |
Expand Down
2 changes: 1 addition & 1 deletion script/lint
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for source in Package.swift Sources Tests; do
done

printf -- $'--> 🐚 ShellCheck\n'
shellcheck -s bash -o all -e SC1088,SC1102,SC2296,SC2299,SC2300,SC2301,SC2312 -a -P SCRIPTDIR script/**/*(.)
shellcheck -s bash -o all -e SC1088,SC1102,SC2066,SC2296,SC2299,SC2300,SC2301,SC2312 -a -P SCRIPTDIR script/**/*(.)
((exit_code |= ${?}))

printf -- $'--> 〽️ Markdown\n'
Expand Down
15 changes: 14 additions & 1 deletion script/version
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

. "${0:a:h}/_setup_script"

printf $'%s%s\n'\
branch="${"$(git rev-parse --abbrev-ref HEAD)":/main}"

if [[ "${branch}" = HEAD ]]; then
if git merge-base --is-ancestor HEAD main; then
branch=
else
branch="${"$(for branch in "${(@)"${(@)"${(f)"$(git branch --contains "$(git rev-parse HEAD)")"}":1}"##* }"; do
printf $'%s %s\n' "$(git rev-list --count HEAD.."${branch}")" "${branch}"
done | sort -nr | head -n 1)"##* }"
fi
fi

printf $'%s%s%s\n'\
"${"$(git describe --tags 2>/dev/null)"#v}"\
"${branch:+"-${branch}"}"\
"${"$(git diff-index HEAD --;git ls-files --exclude-standard --others)":+"${MAS_DIRTY_INDICATOR-+}"}"

0 comments on commit b7964ec

Please sign in to comment.