diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 7d68f62..89b762f 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -27,28 +27,55 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - - name: Check if version tag exists + - name: Check and increment version id: check run: | + # Get current version 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 - echo "Tag v$VERSION already exists" - echo "should_release=false" >> $GITHUB_OUTPUT + echo "Tag v$VERSION already exists, incrementing patch version..." + + # 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 echo "Tag v$VERSION does not exist, will create release" + echo "version=$VERSION" >> $GITHUB_OUTPUT echo "should_release=true" >> $GITHUB_OUTPUT fi build-windows: runs-on: windows + needs: [check-version] + if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped') steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: false + ref: ${{ github.ref_name }} clean: false - name: Checkout submodules (Windows workaround) @@ -133,12 +160,15 @@ jobs: build-linux: runs-on: linux + needs: [check-version] + if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped') steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ github.ref_name }} - name: Setup Node.js uses: actions/setup-node@v4 @@ -231,12 +261,15 @@ jobs: build-android: runs-on: windows + needs: [check-version] + if: always() && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped') steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: recursive + ref: ${{ github.ref_name }} - name: Setup Node.js uses: actions/setup-node@v4 @@ -388,28 +421,36 @@ jobs: create-release: runs-on: linux 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: - name: Checkout repository 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 + if: ${{ !startsWith(github.ref, 'refs/tags/') }} run: | git config user.name "GitHub Actions" 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 push origin "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${{ steps.version.outputs.VERSION }}" - name: Download all artifacts uses: actions/download-artifact@v3 with: path: artifacts - - name: Get version - id: version - run: echo "VERSION=${{ needs.check-version.outputs.version }}" >> $GITHUB_OUTPUT - - name: Create update.json run: | VERSION="${{ steps.version.outputs.VERSION }}"