fix: update the prerelease logic

This commit is contained in:
Nate Kelley 2025-01-16 14:54:51 -07:00
parent 500e5ddc31
commit 3016e16afb
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 21 additions and 31 deletions

View File

@ -22,52 +22,42 @@ jobs:
fetch-depth: 0 # Fetch all history
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Step 3: Install Dependencies
- name: Install Dependencies
run: npm install standard-version --save-dev
# Step 4: Determine New Version
# Step 2: Determine Version
- name: Determine Version
id: get_version
run: |
# Debug: List directory contents
echo "Listing directory contents:"
ls -la
# Debug: Check if version.txt exists
if [ -f "version.txt" ]; then
echo "version.txt exists"
else
echo "version.txt does not exist"
if [ ! -f "version.txt" ]; then
echo "0.0.1" > version.txt
fi
# Read the current version
CURRENT_VERSION=$(cat version.txt)
echo "Current Version: $CURRENT_VERSION"
# Get the next version using standard-version
NEW_VERSION=$(npx standard-version --dry-run | grep "tagging release" | awk '{print $NF}')
# Split version into components
IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION"
MAJOR="${version_parts[0]}"
MINOR="${version_parts[1]}"
PATCH="${version_parts[2]}"
# Increment patch version
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
echo "New Version: $NEW_VERSION"
# Export both versions for later steps
# Export versions for later steps
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
# Step 5: Update version.txt if version changes
# Step 3: Update version.txt if version changes
- name: Update version.txt
if: env.CURRENT_VERSION != env.NEW_VERSION # Run only if the versions are different
if: env.CURRENT_VERSION != env.NEW_VERSION
run: |
echo "$NEW_VERSION" > version.txt
# Step 6: Commit and Push Changes
# Step 4: Commit and Push Changes
- name: Commit and Push Changes
if: env.CURRENT_VERSION != env.NEW_VERSION # Run only if the versions are different
if: env.CURRENT_VERSION != env.NEW_VERSION
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

View File

@ -1 +1 @@
0.0.1