fix: enhance versioning logic and checkout process in build workflow
This commit is contained in:
@@ -27,28 +27,55 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Check if version tag exists
|
- name: Check and increment version
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
|
# Get current version
|
||||||
VERSION=$(grep -Po '"version":\s*"\K[^"]+' src-tauri/tauri.conf.json | head -1)
|
VERSION=$(grep -Po '"version":\s*"\K[^"]+' src-tauri/tauri.conf.json | head -1)
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "Current version: $VERSION"
|
||||||
|
|
||||||
|
# Check if tag exists
|
||||||
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
||||||
echo "Tag v$VERSION already exists"
|
echo "Tag v$VERSION already exists, incrementing patch version..."
|
||||||
echo "should_release=false" >> $GITHUB_OUTPUT
|
|
||||||
|
# Parse version components
|
||||||
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
|
||||||
|
NEW_PATCH=$((PATCH + 1))
|
||||||
|
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
|
||||||
|
|
||||||
|
echo "New version: $NEW_VERSION"
|
||||||
|
|
||||||
|
# Update tauri.conf.json
|
||||||
|
sed -i "s/\"version\": \"$VERSION\"/\"version\": \"$NEW_VERSION\"/" src-tauri/tauri.conf.json
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
git add src-tauri/tauri.conf.json
|
||||||
|
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
|
||||||
|
git push
|
||||||
|
|
||||||
|
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_release=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "Tag v$VERSION does not exist, will create release"
|
echo "Tag v$VERSION does not exist, will create release"
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "should_release=true" >> $GITHUB_OUTPUT
|
echo "should_release=true" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
runs-on: windows
|
runs-on: windows
|
||||||
|
needs: [check-version]
|
||||||
|
if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: false
|
submodules: false
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
clean: false
|
clean: false
|
||||||
|
|
||||||
- name: Checkout submodules (Windows workaround)
|
- name: Checkout submodules (Windows workaround)
|
||||||
@@ -133,12 +160,15 @@ jobs:
|
|||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
|
needs: [check-version]
|
||||||
|
if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -231,12 +261,15 @@ jobs:
|
|||||||
|
|
||||||
build-android:
|
build-android:
|
||||||
runs-on: windows
|
runs-on: windows
|
||||||
|
needs: [check-version]
|
||||||
|
if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -388,28 +421,36 @@ jobs:
|
|||||||
create-release:
|
create-release:
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
needs: [check-version, build-windows, build-linux, build-android]
|
needs: [check-version, build-windows, build-linux, build-android]
|
||||||
if: needs.check-version.outputs.should_release == 'true'
|
if: always() && !cancelled() && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success') && (startsWith(github.ref, 'refs/tags/v') || needs.check-version.outputs.should_release == 'true')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get version from tag or check-version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
||||||
|
VERSION="${{ github.ref_name }}"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
else
|
||||||
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
|
fi
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Create and push tag
|
- name: Create and push tag
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git config user.name "GitHub Actions"
|
||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
git tag -a "v${{ needs.check-version.outputs.version }}" -m "Release v${{ needs.check-version.outputs.version }}"
|
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
|
||||||
git push origin "v${{ needs.check-version.outputs.version }}"
|
git push origin "v${{ steps.version.outputs.VERSION }}"
|
||||||
|
|
||||||
- name: Download all artifacts
|
- name: Download all artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
||||||
- name: Get version
|
|
||||||
id: version
|
|
||||||
run: echo "VERSION=${{ needs.check-version.outputs.version }}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create update.json
|
- name: Create update.json
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user