Skip to content

Commit 067a98f

Browse files
committed
ci: update version computation logic in CI workflow
1 parent 23192ba commit 067a98f

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ on:
99
pull_request:
1010
workflow_dispatch:
1111

12-
permissions:
13-
contents: write
1412

15-
concurrency:
16-
group: ci-${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref_name }}
17-
cancel-in-progress: true
13+
#concurrency:
14+
# group: ci-${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref_name }}
15+
# cancel-in-progress: true
1816

1917
env:
2018
ROOT: "${{ github.workspace }}"
@@ -244,10 +242,29 @@ jobs:
244242
cache: true
245243

246244
- name: Compute PKG_VER
247-
id: ver
248245
shell: bash
249246
run: |
250-
PKG_VER="${GITHUB_REF_NAME#v}"
247+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
248+
# Extract the tag name
249+
tag="${GITHUB_REF#refs/tags/}"
250+
251+
# Remove leading "v" if present
252+
PKG_VER="${tag#v}"
253+
else
254+
# Get the latest tag, or fall back to "v0.0.0" if none exist
255+
cv=$(git describe --abbrev=0 2>/dev/null || echo "v0.0.0")
256+
# Remove leading "v" if present
257+
cv=${cv#v}
258+
259+
# Split into major/minor components
260+
major=$(echo "$cv" | cut -d. -f1)
261+
minor=$(echo "$cv" | cut -d. -f2)
262+
263+
# Construct the package version: <major>.<minor>.0
264+
PKG_VER="${major}.${minor}.${GITHUB_RUN_NUMBER}"
265+
fi
266+
267+
export PKG_VER
251268
echo "PKG_VER=$PKG_VER" | tee -a "$GITHUB_ENV"
252269
253270
- name: Configure pub.dev credentials

0 commit comments

Comments
 (0)