fix issue with tag name 🛠️ #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: [master] # Trigger only on pushes to the main branch | |
jobs: | |
build-and-release: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
components: rustfmt, clippy | |
override: true | |
- name: Extract version from Cargo.toml | |
id: extract_version | |
run: | | |
Get-Content Cargo.toml | Select-String -Pattern '^version\s*=\s*"([^"]+)"' | ForEach-Object { $_.Matches[0].Groups[1].Value } | Set-Content -Path version.txt | |
echo ::set-output name=version::$(Get-Content version.txt) | |
- name: Get latest release version | |
id: get_latest_release | |
run: | | |
$release = curl -sL https://api.github.com/repos/MrEnder0/Wootili-view/releases/latest | ConvertFrom-Json | |
echo ::set-output name=tag_name::$(echo $release.tag_name) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build binaries | |
if: ${{ steps.extract_version.outputs.version != steps.get_latest_release.outputs.tag_name }} | |
run: | | |
rustup target add x86_64-pc-windows-gnu | |
cargo build --release --target x86_64-pc-windows-gnu | |
- name: Create release | |
if: ${{ steps.extract_version.outputs.version != steps.get_latest_release.outputs.tag_name }} | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.extract_version.outputs.version }} | |
release_name: Release ${{ steps.extract_version.outputs.version }} | |
body: | | |
## Changes | |
## Downloads | |
- **Windows binary:** [link to Windows binary] | |
- **Linux binary:** [link to Linux binary] | |
draft: false | |
prerelease: false |