Skip to content

added ci

added ci #2

name: Build and Release
on:
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.4'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build executable
run: python src/setup.py build
- name: Zip HeadsetControl-Qt folder
run: |
$zipFile = "build/HeadsetControl-Qt_win64.zip"
$folder = "build/HeadsetControl-Qt"
Compress-Archive -Path $folder -DestinationPath $zipFile
shell: pwsh
- name: Upload HeadsetControl-Qt zip
uses: actions/upload-artifact@v3
with:
name: HeadsetControl-Qt
path: build/HeadsetControl-Qt_win64.zip
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download HeadsetControl-Qt zip
uses: actions/download-artifact@v3
with:
name: HeadsetControl-Qt
- name: Bump version and create release
id: bump_release
run: |
git fetch --tags
# Determine the latest major version tag
LAST_MAJOR_TAG=$(git tag --list 'v*.*.*' | sed -E 's/^v?([0-9]+)\..*/\1/' | sort -nr | head -n 1)
# Increment the major version number
if [ -z "$LAST_MAJOR_TAG" ]; then
NEW_TAG="v1"
else
NEW_TAG="v$(($LAST_MAJOR_TAG + 1))"
fi
# Check if the tag already exists
if git rev-parse "$NEW_TAG" >/dev/null 2>&1; then
echo "Tag '$NEW_TAG' already exists. Incrementing to next major version."
LAST_MAJOR_TAG=$(git tag --list 'v*' | sed -E 's/^v?([0-9]+).*/\1/' | sort -nr | head -n 1)
NEW_TAG="v$(($LAST_MAJOR_TAG + 1))"
fi
echo "New tag is $NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.new_tag }}
release_name: ${{ env.new_tag }}
body: ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release assets
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: HeadsetControl-Qt_win64.zip
asset_name: HeadsetControl-Qt_win64.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}