From 2eae112d7517846108581037d3c1b907f4ad52f5 Mon Sep 17 00:00:00 2001 From: Odizinne Date: Fri, 26 Jul 2024 13:34:18 +0200 Subject: [PATCH] added ci --- .github/workflows/build-and-release.yaml | 99 ++++++++++++++++++++++++ README.md | 1 + 2 files changed, 100 insertions(+) create mode 100644 .github/workflows/build-and-release.yaml diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml new file mode 100644 index 0000000..7bd202e --- /dev/null +++ b/.github/workflows/build-and-release.yaml @@ -0,0 +1,99 @@ +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 }} diff --git a/README.md b/README.md index c1b3151..c4265d3 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,4 @@ Then run it: `headsetcontrol-qt.py` ## To-do - Add other headsetcontrol supported settings (My headset does not support them so i cannot test) +- Build linux appimage \ No newline at end of file