Skip to content

Commit 092b423

Browse files
authored
Merge pull request #363 from nix-community/version-number
Generate version number from tag name
2 parents 0bfd646 + 3a6103d commit 092b423

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

.github/workflows/run_build.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ jobs:
2424

2525
- name: Generate Version 🏷️
2626
id: version
27+
shell: pwsh
2728
run: |
28-
TAG_COUNT=$(git rev-list --tags --no-walk --count) # Count all tags
29-
COMMIT_COUNT=$(git rev-list --use-bitmap-index --count $(git rev-list --tags --no-walk --max-count=1)..HEAD) # Count all commits since the last tag
30-
NIXOS_VERSION=$(nix-instantiate --eval -E '(import ./.).inputs.nixpkgs.lib.version' | sed -E 's/"(.+\...).*"/\1/') # Get NixOS version from nixpkgs
31-
NIXOS_VERSION_MS=$(echo $NIXOS_VERSION | sed -E 's/\.0*(.+)/\.\1/') # Remove the leading 0 from the minor version (if it exists)
32-
NIXOS_WSL_VERSION=${NIXOS_VERSION_MS}.${TAG_COUNT}.${COMMIT_COUNT} # Compose the NixOS-WSL version number
33-
echo "version=$NIXOS_WSL_VERSION" >> $GITHUB_OUTPUT
29+
$LATEST_TAG = git describe --tags --abbrev=0 # Get the latest tag name
30+
$COMMIT_COUNT = git rev-list --use-bitmap-index --count $(git rev-list --tags --no-walk --max-count=1)..HEAD # Count all commits since the last tag
31+
$NIXOS_WSL_VERSION = "$($LATEST_TAG -replace '(.+)\.(.+)\.(.+)\..+', '$1.$2.$3').${COMMIT_COUNT}" # Compose the NixOS-WSL version number
32+
echo "version=$NIXOS_WSL_VERSION" >> $env:GITHUB_OUTPUT
3433
3534
echo $NIXOS_WSL_VERSION > ./VERSION
3635
echo $(git rev-parse HEAD) >> ./VERSION

0 commit comments

Comments
 (0)