Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA: Use SHA from PR HEAD commit for pkg name #1124

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading