Skip to content

chore(release): Bump to v0.2.12 #54

chore(release): Bump to v0.2.12

chore(release): Bump to v0.2.12 #54

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
create-release:
name: Create GitHub Release
runs-on: windows-latest
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Extract Version
shell: pwsh
run: |
$VERSION = $env:GITHUB_REF -replace '^refs/tags/v',''
echo "Extracted version: $VERSION"
echo "ARTIFACT_VERSION=$VERSION" >> $env:GITHUB_ENV
$SHORT_SHA = git rev-parse --short HEAD
echo "Extracted short SHA: $SHORT_SHA"
echo "SHORT_SHA=$SHORT_SHA" >> $env:GITHUB_ENV
- name: Build Project
run: |
cargo build --release --bin pubg_controller
env:
CARGO_TERM_COLOR: always
- name: Archive Build Artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts
Copy-Item target/release/pubg_controller.exe artifacts/
- name: Generate Release Notes
id: release_notes
shell: pwsh
run: |
# Fetch full history and tags
git fetch --unshallow
git fetch --tags
# Get the current tag from the GitHub ref
$currentTag = $env:GITHUB_REF -replace '^refs/tags/',''
# Get the previous tag
$lastTag = $(git describe --tags --abbrev=0 "$currentTag^")
# Capture full commit messages
$rawCommits = $(git log "$lastTag..$currentTag" --pretty=format:"%h%n%s%n%b%n---COMMIT_SEPARATOR---" --no-merges)
# Process commits
$processedCommits = @()
$currentCommit = @{
Hash = $null
Subject = $null
Body = $null
}
$rawCommits -split "`n" | ForEach-Object {
if ($_ -eq "---COMMIT_SEPARATOR---") {
if ($currentCommit.Hash) {
$formattedCommit = "### $($currentCommit.Hash) - $($currentCommit.Subject)"
if ($currentCommit.Body) {
$formattedCommit += "`n$($currentCommit.Body)"
}
$processedCommits += $formattedCommit
}
$currentCommit = @{
Hash = $null
Subject = $null
Body = $null
}
}
elseif (-not $currentCommit.Hash) {
$currentCommit.Hash = $_
}
elseif (-not $currentCommit.Subject) {
$currentCommit.Subject = $_
}
else {
if ($_ -and $_ -ne "---COMMIT_SEPARATOR---") {
$currentCommit.Body += "$_`n"
}
}
}
# Separate commits into categories
$features = $processedCommits | Where-Object { $_ -match "### \w+ - feat" }
$fixes = $processedCommits | Where-Object { $_ -match "### \w+ - fix" }
# Initialize release notes
$releaseNotes = "Automated release message`n`n## Changes since $lastTag`n`n"
# Add features section if exists
if ($features) {
$releaseNotes += "### 🚀 Features`n"
$releaseNotes += ($features -join "`n`n") + "`n`n"
}
# Add fixes section if exists
if ($fixes) {
$releaseNotes += "### 🐛 Bug Fixes`n"
$releaseNotes += ($fixes -join "`n`n") + "`n`n"
}
# Prepare additional sections
$featuresSection = "## 🛠️ Features`n- Distance from players`n- Players health`n- Angle to players`n`n## 🔧 Setup Requirements`n- Premium Zenith driver (available at https://valth.run/)`n- Run the executable in VM or WSL (for better safety)"
# Combine release notes with additional sections
$fullReleaseNotes = $releaseNotes + $featuresSection
$fullReleaseNotes = $fullReleaseNotes -replace "'", "''"
echo "RELEASE_NOTES<<EOF" >> $env:GITHUB_ENV
echo "$fullReleaseNotes" >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: "v${{ env.ARTIFACT_VERSION }}"
body: ${{ env.RELEASE_NOTES }}
draft: false
prerelease: false
- name: Upload Windows Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/pubg_controller.exe
asset_name: "pubg_enhancer_${{ env.SHORT_SHA }}.exe"
asset_content_type: application/octet-stream
build-linux:
name: Build Linux Executable
runs-on: ubuntu-latest
needs: create-release
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Extract Version
shell: bash
run: |
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\/v//')
echo "Extracted version: $VERSION"
echo "ARTIFACT_VERSION=$VERSION" >> $GITHUB_ENV
SHORT_SHA=$(git rev-parse --short HEAD)
echo "Extracted short SHA: $SHORT_SHA"
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
- name: Build Linux Project
run: |
cargo build --release --bin pubg_controller
env:
CARGO_TERM_COLOR: always
- name: Archive Linux Build Artifacts
shell: bash
run: |
mkdir -p artifacts
cp target/release/pubg_controller artifacts/
- name: Get Release Upload URL
id: get_release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = context.ref.replace('refs/tags/', '');
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
return release.data.upload_url;
result-encoding: string
- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.result }}
asset_path: artifacts/pubg_controller
asset_name: "pubg_enhancer_${{ env.SHORT_SHA }}"
asset_content_type: application/octet-stream