Skip to content

Commit

Permalink
Merge pull request #1124 from tleedjarv/gha-gitsha
Browse files Browse the repository at this point in the history
GHA: Use SHA from PR HEAD commit for pkg name
  • Loading branch information
gdt authored Feb 20, 2025
2 parents bd48168 + 979aeca commit b46dd86
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,20 @@ jobs:
STAGING_DIR='_staging'
outputs STAGING_DIR
# parse commit reference info
GIT_SHA=${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
echo GITHUB_REF=${GITHUB_REF}
echo GITHUB_SHA=${GITHUB_SHA}
echo GIT_SHA=${GIT_SHA}
REF_NAME="${GITHUB_REF#refs/*/}"
unset REF_BRANCH ; case "${GITHUB_REF}" in refs/heads/*) REF_BRANCH="${GITHUB_REF#refs/heads/}" ;; esac;
unset REF_TAG ; case "${GITHUB_REF}" in refs/tags/*) REF_TAG="${GITHUB_REF#refs/tags/}" ;; esac;
REF_SHAS="${GITHUB_SHA:0:8}"
REF_SHAS="${GIT_SHA:0:8}"
outputs REF_BRANCH REF_NAME REF_SHAS REF_TAG
# deployable tag? (ie, leading "vM" or "M"; M == version number)
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
outputs DEPLOY
# package name
PKG_suffix='.tar.gz' ; case '${{ matrix.job.os }}' in windows-*) PKG_suffix='.zip' ;; esac;
PKG_VER="${REF_TAG:-git_$REF_SHAS}"
PKG_VER="${REF_TAG:${{ github.event_name == 'pull_request' && format('-unmerged-pr-{0}', github.event.pull_request.number) || '' }}-git_$REF_SHAS}"
PKG_VER="${PKG_VER#v}"
PKG_BASENAME="unison-${PKG_VER}${{ matrix.job.fnsuffix }}"
PKG_NAME="${PKG_BASENAME}${PKG_suffix}"
Expand Down Expand Up @@ -1108,9 +1109,9 @@ jobs:
- name: Initialize packaging variables
id: vars
run: |
REF_SHAS=$(echo '${{ github.sha }}' | awk '{ print substr($0, 1, 8) }')
REF_SHAS=$(echo '${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}' | awk '{ print substr($0, 1, 8) }')
unset REF_TAG ; case "${GITHUB_REF}" in refs/tags/*) REF_TAG="${GITHUB_REF#refs/tags/}" ;; esac;
PKG_VER="${REF_TAG:-git_$REF_SHAS}"
PKG_VER="${REF_TAG:${{ github.event_name == 'pull_request' && format('-unmerged-pr-{0}', github.event.pull_request.number) || '' }}-git_$REF_SHAS}"
PKG_VER="${PKG_VER#v}"
echo PKG_DIR="unison-${PKG_VER}${{ matrix.job.fnsuffix }}" >> $GITHUB_OUTPUT
echo PKG_NAME="unison-${PKG_VER}${{ matrix.job.fnsuffix }}.tar.gz" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit b46dd86

Please sign in to comment.