From d33ee0c69edfa850bd556001fe72ed5b3caf1629 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:43:38 +0000 Subject: [PATCH] chore: consolidate and optimize github actions workflows Replaced 6 separate, redundant workflow files (`git-archive.yml`, `git-deb.yml`, `git-flatpak.yml`, `release-archive.yml`, `release-deb.yml`, `release-flatpak.yml`) with 2 consolidated workflows (`build.yml` and `release.yml`). - Consolidated `.zip` and `.deb` building into a single `linux-build` and `linux-release` job to avoid running `cargo build --release` multiple times. - Added parallel `flatpak-build` and `flatpak-release` jobs to the respective unified workflows. - Improved `release.yml` with a `prepare` job that correctly queries and passes the release tag to dependent build jobs. - Fixed an issue in the `prepare` job where an undefined bash `$GITHUB_TOKEN` was used instead of `${{ secrets.GITHUB_TOKEN }}`. Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com> --- .../workflows/{git-archive.yml => build.yml} | 41 ++++++- .github/workflows/git-deb.yml | 53 --------- .github/workflows/git-flatpak.yml | 27 ----- .github/workflows/release-deb.yml | 102 ------------------ .github/workflows/release-flatpak.yml | 72 ------------- .../{release-archive.yml => release.yml} | 83 +++++++++++--- 6 files changed, 105 insertions(+), 273 deletions(-) rename .github/workflows/{git-archive.yml => build.yml} (68%) delete mode 100644 .github/workflows/git-deb.yml delete mode 100644 .github/workflows/git-flatpak.yml delete mode 100644 .github/workflows/release-deb.yml delete mode 100644 .github/workflows/release-flatpak.yml rename .github/workflows/{release-archive.yml => release.yml} (66%) diff --git a/.github/workflows/git-archive.yml b/.github/workflows/build.yml similarity index 68% rename from .github/workflows/git-archive.yml rename to .github/workflows/build.yml index a1a047e..a50ae64 100644 --- a/.github/workflows/git-archive.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Git archive +name: Build permissions: contents: write @@ -7,10 +7,12 @@ permissions: on: push: branches: [main, master] + pull_request: + branches: [main, master] workflow_dispatch: jobs: - build-and-upload: + linux-build: runs-on: ubuntu-latest steps: @@ -39,7 +41,6 @@ jobs: set -euo pipefail BIN_NAMES=$(cargo metadata --no-deps --format-version 1 \ | jq -r '.packages[0].targets[] | select(.kind[] | contains("bin")) | .name') - # сохраним построчно в выход echo "bin_names<> $GITHUB_OUTPUT echo "$BIN_NAMES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT @@ -82,3 +83,37 @@ jobs: name: archive path: pwsp-*.zip retention-days: 7 + + - name: Install cargo-deb and create .deb + shell: bash + run: | + set -euo pipefail + cargo install --locked cargo-deb + export PATH="$HOME/.cargo/bin:$PATH" + + cargo-deb + + - name: Upload .deb(s) as artifacts + uses: actions/upload-artifact@v4 + with: + name: deb-packages + path: target/debian/*.deb + retention-days: 7 + + flatpak-build: + runs-on: ubuntu-latest + container: + image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08 + options: --privileged + + steps: + - uses: actions/checkout@v4 + + - name: Build Flatpak + uses: flatpak/flatpak-github-actions/flatpak-builder@v6 + with: + bundle: ru.arabianq.pwsp.flatpak + manifest-path: packages/flatpak/ru.arabianq.pwsp.yaml + cache: true + branch: master + build-bundle: true diff --git a/.github/workflows/git-deb.yml b/.github/workflows/git-deb.yml deleted file mode 100644 index b94b2ca..0000000 --- a/.github/workflows/git-deb.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Git deb - -permissions: - contents: write - packages: write - -on: - push: - branches: [main, master] - workflow_dispatch: - -jobs: - build-and-upload: - runs-on: ubuntu-latest - - steps: - - name: Install apt deps (jq/zip + dev-libs) - run: | - sudo apt-get update - sudo apt-get install -y \ - zip jq \ - libpipewire-0.3-dev \ - libclang-dev \ - libasound2-dev - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - - name: Build all release binaries - run: cargo build --release --locked - - - name: Install cargo-deb and create .deb - shell: bash - run: | - set -euo pipefail - cargo install --locked cargo-deb - export PATH="$HOME/.cargo/bin:$PATH" - - cargo-deb - - - name: Upload .deb(s) as artifacts - uses: actions/upload-artifact@v4 - with: - name: deb-packages - path: target/debian/*.deb - retention-days: 7 diff --git a/.github/workflows/git-flatpak.yml b/.github/workflows/git-flatpak.yml deleted file mode 100644 index 0cdc90d..0000000 --- a/.github/workflows/git-flatpak.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Git Flatpak - -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - workflow_dispatch: - -jobs: - flatpak-build: - runs-on: ubuntu-latest - container: - image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08 - options: --privileged - - steps: - - uses: actions/checkout@v4 - - - name: Build Flatpak - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 - with: - bundle: ru.arabianq.pwsp.flatpak - manifest-path: packages/flatpak/ru.arabianq.pwsp.yaml - cache: true - branch: master - build-bundle: true diff --git a/.github/workflows/release-deb.yml b/.github/workflows/release-deb.yml deleted file mode 100644 index 89b0eef..0000000 --- a/.github/workflows/release-deb.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Release deb - -permissions: - contents: write - packages: write - -on: - release: - types: [created] - workflow_dispatch: - inputs: - tag: - description: "Tag to attach assets to (e.g. v1.0.0)" - required: false - -jobs: - build-and-release: - runs-on: ubuntu-latest - - steps: - - name: Install apt deps (jq/zip + dev-libs) - run: | - sudo apt-get update - sudo apt-get install -y \ - zip jq \ - libpipewire-0.3-dev \ - libclang-dev \ - libasound2-dev - - - name: Determine tag to use - id: tag - run: | - set -euo pipefail - - INPUT_TAG="${{ github.event.inputs.tag || '' }}" - if [ -n "$INPUT_TAG" ]; then - echo "Using input tag: $INPUT_TAG" - echo "tag=$INPUT_TAG" >> $GITHUB_OUTPUT - exit 0 - fi - - EVENT_TAG="${{ github.event.release.tag_name || '' }}" - if [ -n "$EVENT_TAG" ]; then - echo "Using event tag: $EVENT_TAG" - echo "tag=$EVENT_TAG" >> $GITHUB_OUTPUT - exit 0 - fi - - if [[ "${GITHUB_REF:-}" =~ ^refs/tags/(.+)$ ]]; then - echo "Using GITHUB_REF tag: ${BASH_REMATCH[1]}" - echo "tag=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "No tag in input/event/GITHUB_REF — querying latest release via API..." - LATEST_JSON=$(curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository }}/releases/latest" || true) - TAG_NAME=$(echo "$LATEST_JSON" | jq -r '.tag_name // empty') - if [ -n "$TAG_NAME" ]; then - echo "Found latest release tag: $TAG_NAME" - echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "No tag found" - echo "tag=" >> $GITHUB_OUTPUT - - - name: Fail if no tag determined - if: ${{ steps.tag.outputs.tag == '' }} - run: | - echo "ERROR: No tag determined. Provide a tag when running manually or ensure a release exists." - exit 1 - - - name: Checkout code at tag - uses: actions/checkout@v4 - with: - ref: ${{ steps.tag.outputs.tag || github.ref }} - fetch-depth: 0 - - - name: Setup Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - - name: Build all release binaries - run: cargo build --release --locked - - - name: Install cargo-deb and create .deb - shell: bash - run: | - set -euo pipefail - cargo install --locked cargo-deb - export PATH="$HOME/.cargo/bin:$PATH" - - cargo-deb - - - name: Upload .deb(s) to release - uses: softprops/action-gh-release@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ steps.tag.outputs.tag }} - files: | - target/debian/*.deb diff --git a/.github/workflows/release-flatpak.yml b/.github/workflows/release-flatpak.yml deleted file mode 100644 index 90df070..0000000 --- a/.github/workflows/release-flatpak.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Release Flatpak - -permissions: - contents: write - -on: - release: - types: [created] - workflow_dispatch: - inputs: - tag: - description: "Tag to attach assets to (e.g. v1.0.0)" - required: false - -jobs: - flatpak-release: - runs-on: ubuntu-latest - container: - image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08 - options: --privileged - - steps: - - name: Determine tag to use - id: tag - run: | - set -euo pipefail - - INPUT_TAG="${{ github.event.inputs.tag || '' }}" - if [ -n "$INPUT_TAG" ]; then - echo "tag=$INPUT_TAG" >> $GITHUB_OUTPUT - exit 0 - fi - - EVENT_TAG="${{ github.event.release.tag_name || '' }}" - if [ -n "$EVENT_TAG" ]; then - echo "tag=$EVENT_TAG" >> $GITHUB_OUTPUT - exit 0 - fi - - if [[ "${GITHUB_REF:-}" =~ ^refs/tags/(.+)$ ]]; then - echo "tag=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "No tag found" - echo "tag=" >> $GITHUB_OUTPUT - - - name: Fail if no tag determined - if: ${{ steps.tag.outputs.tag == '' }} - run: | - echo "ERROR: No tag determined." - exit 1 - - - uses: actions/checkout@v4 - with: - ref: ${{ steps.tag.outputs.tag }} - - - name: Build Flatpak - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 - with: - bundle: ru.arabianq.pwsp.flatpak - manifest-path: packages/flatpak/ru.arabianq.pwsp.yaml - cache: true - branch: master - build-bundle: true - - - name: Upload Flatpak to release - uses: softprops/action-gh-release@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ steps.tag.outputs.tag }} - files: ru.arabianq.pwsp.flatpak diff --git a/.github/workflows/release-archive.yml b/.github/workflows/release.yml similarity index 66% rename from .github/workflows/release-archive.yml rename to .github/workflows/release.yml index 4118612..9bc21a9 100644 --- a/.github/workflows/release-archive.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release archive +name: Release permissions: contents: write @@ -14,19 +14,11 @@ on: required: false jobs: - build-and-release: + prepare: runs-on: ubuntu-latest - + outputs: + tag: ${{ steps.tag.outputs.tag }} steps: - - name: Install apt deps (jq/zip + dev-libs) - run: | - sudo apt-get update - sudo apt-get install -y \ - zip jq \ - libpipewire-0.3-dev \ - libclang-dev \ - libasound2-dev - - name: Determine tag to use id: tag run: | @@ -53,7 +45,7 @@ jobs: fi echo "No tag in input/event/GITHUB_REF — querying latest release via API..." - LATEST_JSON=$(curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository }}/releases/latest" || true) + LATEST_JSON=$(curl -sSf -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository }}/releases/latest" || true) TAG_NAME=$(echo "$LATEST_JSON" | jq -r '.tag_name // empty') if [ -n "$TAG_NAME" ]; then echo "Found latest release tag: $TAG_NAME" @@ -70,10 +62,24 @@ jobs: echo "ERROR: No tag determined. Provide a tag when running manually or ensure a release exists." exit 1 + linux-release: + needs: prepare + runs-on: ubuntu-latest + + steps: + - name: Install apt deps (jq/zip + dev-libs) + run: | + sudo apt-get update + sudo apt-get install -y \ + zip jq \ + libpipewire-0.3-dev \ + libclang-dev \ + libasound2-dev + - name: Checkout code at tag uses: actions/checkout@v4 with: - ref: ${{ steps.tag.outputs.tag || github.ref }} + ref: ${{ needs.prepare.outputs.tag }} fetch-depth: 0 - name: Setup Rust toolchain @@ -98,7 +104,7 @@ jobs: shell: bash run: | set -euo pipefail - TAG="${{ steps.tag.outputs.tag }}" + TAG="${{ needs.prepare.outputs.tag }}" ARCHIVE_NAME="pwsp-${TAG}-linux-x64.zip" echo "Creating archive: $ARCHIVE_NAME" @@ -127,6 +133,51 @@ jobs: uses: softprops/action-gh-release@v2 with: token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ steps.tag.outputs.tag }} + tag_name: ${{ needs.prepare.outputs.tag }} files: | pwsp-*.zip + + - name: Install cargo-deb and create .deb + shell: bash + run: | + set -euo pipefail + cargo install --locked cargo-deb + export PATH="$HOME/.cargo/bin:$PATH" + + cargo-deb + + - name: Upload .deb(s) to release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.prepare.outputs.tag }} + files: | + target/debian/*.deb + + flatpak-release: + needs: prepare + runs-on: ubuntu-latest + container: + image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08 + options: --privileged + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare.outputs.tag }} + + - name: Build Flatpak + uses: flatpak/flatpak-github-actions/flatpak-builder@v6 + with: + bundle: ru.arabianq.pwsp.flatpak + manifest-path: packages/flatpak/ru.arabianq.pwsp.yaml + cache: true + branch: master + build-bundle: true + + - name: Upload Flatpak to release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.prepare.outputs.tag }} + files: ru.arabianq.pwsp.flatpak