2
0
Fork 0
mirror of https://github.com/mas-cli/mas synced 2025-03-06 23:57:21 +00:00

Prepend branch name in version name in certain conditions.

Resolve 

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2025-01-05 08:31:09 -05:00
parent a5a928a2e6
commit 75251ea2e2
No known key found for this signature in database
7 changed files with 51 additions and 2 deletions

View file

@ -31,6 +31,9 @@ jobs:
# Include all history & tags for script/version
fetch-depth: 0
- name: Setup repo
run: script/setup_workflow_repo
- name: Bootstrap
run: script/bootstrap

View file

@ -28,7 +28,17 @@ 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: Setup repo
run: script/setup_workflow_repo
- name: Initialize CodeQL
uses: github/codeql-action/init@v3

View file

@ -25,6 +25,12 @@ 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: 🔧 Setup repo
run: script/setup_workflow_repo
- name: 🚰 Apply pr-pull label to custom tap formula bump PR
env:

View file

@ -23,6 +23,12 @@ 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: 🔧 Setup repo
run: script/setup_workflow_repo
- name: 🖋 Delete tag lacking valid signature
run: |

View file

@ -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'

13
script/setup_workflow_repo Executable file
View file

@ -0,0 +1,13 @@
#!/bin/zsh -Ndefgku
#
# script/setup_workflow_repo
# mas
#
# Sets up the repo for use in a GitHub workflow.
#
. "${0:a:h}/_setup_script"
for branch in "${(f)"$(git for-each-ref refs/remotes/origin --format='%(if)%(symref)%(then)%(else)%(refname:strip=-1)%(end)')":#}"; do
git branch --track "${branch}" "origin/${branch}" >/dev/null 2>&1 || true
done

View file

@ -8,6 +8,17 @@
. "${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="${"${(@)"${(fnO)"$(git branch --format '%(ahead-behind:HEAD) %(refname:short)')"}"[1]}"##* }"
fi
fi
printf $'%s%s%s\n'\
"${branch:+"${branch}-"}"\
"${"$(git describe --tags 2>/dev/null)"#v}"\
"${"$(git diff-index HEAD --;git ls-files --exclude-standard --others)":+"${MAS_DIRTY_INDICATOR-+}"}"