From ec2fa2a478c640da1e53a2dbbfd565f4917c41e6 Mon Sep 17 00:00:00 2001 From: arabian Date: Tue, 2 Jun 2026 21:44:56 +0300 Subject: [PATCH] ci: better github actions --- .github/workflows/build.yml | 39 +++++++++++++++------- .github/workflows/flatter.yml | 7 ++-- .github/workflows/release.yml | 62 ++++++++++++----------------------- 3 files changed, 52 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5e9e15..462da69 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,13 +33,22 @@ jobs: fetch-depth: 0 - name: Setup Rust toolchain - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.94.1 + toolchain: 1.96.0 - name: Run tests run: cargo test --locked + - name: Build all binaries (debug-speed compilation into target/release) + env: + CARGO_PROFILE_RELEASE_OPT_LEVEL: 0 + CARGO_PROFILE_RELEASE_DEBUG: "true" + CARGO_PROFILE_RELEASE_STRIP: "false" + CARGO_PROFILE_RELEASE_LTO: "false" + CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 256 + run: cargo build --release --locked + - name: Extract all binary names id: cargo-meta run: | @@ -50,9 +59,6 @@ jobs: echo "$BIN_NAMES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - - name: Build all binaries - run: cargo build --locked - - name: Package all binaries into one archive shell: bash run: | @@ -64,7 +70,7 @@ jobs: FILES=() while IFS= read -r BIN; do [ -z "$BIN" ] && continue - FILES+=("target/debug/$BIN") + FILES+=("target/release/$BIN") done <<< "${{ steps.cargo-meta.outputs.bin_names }}" if [ "${#FILES[@]}" -eq 0 ]; then @@ -89,15 +95,23 @@ jobs: path: pwsp-*.zip retention-days: 7 - - name: Install cargo-deb and create .deb + - name: Cache cargo-deb + id: cache-cargo-deb + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-deb + key: ${{ runner.os }}-cargo-deb-v1 + + - name: Install cargo-deb + if: steps.cache-cargo-deb.outputs.cache-hit != 'true' + run: cargo install --locked cargo-deb + + - name: Create .deb package (debug binaries from target/release) shell: bash run: | set -euo pipefail - cargo install --locked cargo-deb export PATH="$HOME/.cargo/bin:$PATH" - - cargo build --release --locked - cargo-deb -p pwsp-gui + cargo-deb -p pwsp-gui --no-build --no-strip - name: Upload .deb(s) as artifacts uses: actions/upload-artifact@v4 @@ -107,6 +121,7 @@ jobs: retention-days: 7 flatpak-build: + if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest container: image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.08 @@ -122,4 +137,4 @@ jobs: manifest-path: packages/flatpak/ru.arabianq.pwsp.yaml cache: true branch: master - build-bundle: true \ No newline at end of file + build-bundle: true diff --git a/.github/workflows/flatter.yml b/.github/workflows/flatter.yml index c802c26..8f29bc8 100644 --- a/.github/workflows/flatter.yml +++ b/.github/workflows/flatter.yml @@ -2,9 +2,9 @@ name: Flatter on: push: - branches: [ main, master ] + branches: [main, master] release: - types: [ published ] + types: [published] workflow_dispatch: inputs: tag_name: @@ -60,7 +60,8 @@ jobs: echo "default-branch: ${{ steps.set_branch.outputs.branch }}" >> packages/flatpak/ru.arabianq.pwsp.yaml - name: Install SDK Extensions - run: flatpak install -y flathub org.freedesktop.Sdk.Extension.rust-stable//25.08 + run: + flatpak install -y flathub org.freedesktop.Sdk.Extension.rust-stable//25.08 org.freedesktop.Sdk.Extension.llvm20//25.08 - name: Build Flatpak diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fb79d0..a63539d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,9 +85,9 @@ jobs: fetch-depth: 0 - name: Setup Rust toolchain - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.94.1 + toolchain: 1.96.0 - name: Extract all binary names id: cargo-meta @@ -131,49 +131,29 @@ jobs: zip -j "$ARCHIVE_NAME" "${FILES[@]}" - - name: Upload release archive + - name: Cache cargo-deb + id: cache-cargo-deb + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-deb + key: ${{ runner.os }}-cargo-deb-v1 + + - name: Install cargo-deb + if: steps.cache-cargo-deb.outputs.cache-hit != 'true' + run: cargo install --locked cargo-deb + + - name: Create .deb package (release binaries) + shell: bash + run: | + set -euo pipefail + export PATH="$HOME/.cargo/bin:$PATH" + cargo-deb -p pwsp-gui --no-build + + - name: Upload artifacts to Release uses: softprops/action-gh-release@v2 with: token: ${{ secrets.GITHUB_TOKEN }} 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 build --release --locked - cargo-deb -p pwsp-gui - - - 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: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.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