Skip to content

compiling web_search.exe #11

compiling web_search.exe

compiling web_search.exe #11

Workflow file for this run

name: compiling web_search.exe
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Auto-increment version
id: increment_version
shell: pwsh
run: |
$cargoPath = "web_search/Cargo.toml"
$cargoContent = Get-Content $cargoPath
$packageSectionFound = $false
$versionUpdated = $false
$newVersion = ""
for ($i = 0; $i -lt $cargoContent.Length; $i++) {
$line = $cargoContent[$i]
# Найти секцию [package]
if ($line -match '^\[package\]') {
$packageSectionFound = $true
continue
}
if ($packageSectionFound -and -not $versionUpdated -and $line -match '^version\s*=\s*"([^"]+)"') {
$currentVersion = $matches[1]
$versionParts = $currentVersion.Split('.')
$newPatch = [int]$versionParts[2] + 1
$newVersion = "$($versionParts[0]).$($versionParts[1]).$newPatch"
$cargoContent[$i] = "version = `"$newVersion`""
$versionUpdated = $true
Write-Host "Updated version from $currentVersion to $newVersion"
}
if ($packageSectionFound -and $line -match '^\[.*\]' -and $line -notmatch '^\[package\]') {
break
}
}
if (-not $versionUpdated) {
Write-Error "Failed to update version in [package] section"
exit 1
}
Set-Content -Path $cargoPath -Value $cargoContent
echo "NEW_VERSION=$newVersion" >> $env:GITHUB_OUTPUT
echo "New version: $newVersion"
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "ci: Bump version to ${{ steps.increment_version.outputs.NEW_VERSION }}"
file_pattern: "web_search/Cargo.toml"
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Verify Cargo.toml
shell: pwsh
run: |
Write-Host "Current Cargo.toml content:"
Get-Content web_search/Cargo.toml
- name: Build release binary
shell: pwsh
run: cargo build --release --target x86_64-pc-windows-msvc
working-directory: ./web_search
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: web_search-x64
path: web_search/target/x86_64-pc-windows-msvc/release/web_search.exe
- name: Get version
id: version
shell: pwsh
run: |
$version = "${{ steps.increment_version.outputs.NEW_VERSION }}"
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Version: $version"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.VERSION }}
name: Release v${{ steps.version.outputs.VERSION }}
files: web_search/target/x86_64-pc-windows-msvc/release/web_search.exe
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}