Skip to content

Commit

Permalink
Refine package building workflow in GitHub Actions
Browse files Browse the repository at this point in the history
The updates in this commit refine the way branch names and package prefixes are determined in the GitHub workflow for package building. Moreover, the workflow now recognizes and supports additional branch patterns, including 'patch/*' and 'preview/*', extending the existing support for 'main' and 'feature/*' branches.
  • Loading branch information
sfmskywalker committed Feb 14, 2024
1 parent 67feaab commit ff7c5dc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- 'main'
- 'feature/*'
- 'patch/*'
release:
types: [ prereleased, published ]
env:
Expand All @@ -19,8 +20,21 @@ jobs:
steps:
- name: Extract branch name
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | rev | cut -d/ -f1 | rev)" >> $GITHUB_ENV
echo "Branch name: $BRANCH_NAME"
BRANCH_NAME=${{ github.ref }} # e.g., refs/heads/main
BRANCH_NAME=${BRANCH_NAME#refs/heads/} # remove the refs/heads/ prefix
# Extract the last part after the last slash of the branch name, if any, e.g., feature/issue-123 -> issue-123 and use it as the version prefix.
PACKAGE_PREFIX=$(echo $BRANCH_NAME | rev | cut -d/ -f1 | rev)
# If the branch name is main, use the preview version. Otherwise, use the branch name as the version prefix.
if [[ "${BRANCH_NAME}" == "main" ]]; then
PACKAGE_PREFIX="preview"
fi
echo "Ref: ${{ github.ref }}"
echo "Branch name: ${BRANCH_NAME}"
echo "Package prefix: ${PACKAGE_PREFIX}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
echo "PACKAGE_PREFIX=${PACKAGE_PREFIX}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Verify commit exists in branch
Expand All @@ -34,12 +48,7 @@ jobs:
TAG_NAME=${TAG_NAME#refs/tags/} # remove the refs/tags/ prefix
echo "VERSION=${TAG_NAME}" >> $GITHUB_ENV
else
# if branch name is main, use preview as the version. Otherwise, use the branch name.
if [[ "${BRANCH_NAME}" == "main" ]]; then
echo "VERSION=3.1.0-preview.${{github.run_number}}" >> $GITHUB_ENV
else
echo "VERSION=3.1.0-${BRANCH_NAME}.${{github.run_number}}" >> $GITHUB_ENV
fi
echo "VERSION=3.1.0-${PACKAGE_PREFIX}.${{github.run_number}}" >> $GITHUB_ENV
fi
- name: Compile+Test+Pack
run: ./build.sh Compile+Test+Pack --version ${VERSION}
Expand Down

0 comments on commit ff7c5dc

Please sign in to comment.