conditonal ntfy #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| # Add explicit permissions for the workflow | |
| permissions: | |
| contents: write | |
| packages: read | |
| actions: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasound2-dev pkg-config libdbus-1-dev libxss-dev | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@nightly | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Check binaries | |
| run: | | |
| cargo check --bin auto-beeper-service | |
| cargo check --bin auto-beeper-configurator | |
| build: | |
| name: Build for ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: test | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| suffix: "" | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| suffix: ".exe" | |
| - os: windows-latest | |
| target: x86_64-pc-windows-gnu | |
| suffix: ".exe" | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| suffix: "" | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| suffix: "" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install system dependencies (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasound2-dev pkg-config libdbus-1-dev libxss-dev | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build binaries | |
| run: | | |
| cargo build --release --target ${{ matrix.target }} --bin auto-beeper-service | |
| cargo build --release --target ${{ matrix.target }} --bin auto-beeper-configurator | |
| shell: bash | |
| - name: Build Windows service binary (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cargo build --release --target ${{ matrix.target }} --features windows-service --bin auto-beeper-windows-service | |
| shell: bash | |
| - name: Create release directory | |
| run: mkdir -p release | |
| - name: Copy binaries | |
| run: | | |
| cp target/${{ matrix.target }}/release/auto-beeper-service${{ matrix.suffix }} release/auto-beeper-service-${{ matrix.target }}${{ matrix.suffix }} | |
| cp target/${{ matrix.target }}/release/auto-beeper-configurator${{ matrix.suffix }} release/auto-beeper-configurator-${{ matrix.target }}${{ matrix.suffix }} | |
| shell: bash | |
| - name: Copy Windows service binary (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cp target/${{ matrix.target }}/release/auto-beeper-windows-service${{ matrix.suffix }} release/auto-beeper-windows-service-${{ matrix.target }}${{ matrix.suffix }} | |
| shell: bash | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: beeper-automations-${{ matrix.target }} | |
| path: release/* | |
| create-dev-release: | |
| name: Create Development Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| # Add explicit permissions for this job | |
| permissions: | |
| contents: write | |
| packages: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create release directory | |
| run: mkdir -p release | |
| - name: Organize artifacts | |
| run: | | |
| # Copy all binaries from artifacts directories | |
| find artifacts -name "auto-beeper-*" -type f -exec cp {} release/ \; | |
| # Copy install scripts | |
| cp scripts/install.sh release/install.sh | |
| cp scripts/install.ps1 release/install.ps1 | |
| chmod +x release/install.sh | |
| ls -la release/ | |
| - name: Generate release tag | |
| id: tag | |
| run: | | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| TAG="dev-$(date +'%Y%m%d-%H%M%S')" | |
| BUILD_DATE="$(date +'%B %d, %Y at %H:%M:%S UTC')" | |
| else | |
| TAG="dev-${GITHUB_REF_NAME}-$(date +'%Y%m%d-%H%M%S')" | |
| BUILD_DATE="$(date +'%B %d, %Y at %H:%M:%S UTC')" | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT | |
| echo "Generated tag: $TAG" | |
| echo "Build date: $BUILD_DATE" | |
| - name: Create development release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag }} | |
| name: "Development Release ${{ steps.tag.outputs.tag }}" | |
| body: | | |
| 🚀 **Beeper Automations - Development Release** | |
| This is an automated development release built from the latest code. | |
| **Binaries included:** | |
| - `auto-beeper-service` - Background service for automation execution | |
| - `auto-beeper-configurator` - TUI for configuration management | |
| - `install.sh` - Installation script for Linux and macOS | |
| - `install.ps1` - Installation script for Windows | |
| **Quick Install:** | |
| **Linux/macOS:** | |
| ```bash | |
| curl -sSL https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash | |
| ``` | |
| Or download and run manually: | |
| ```bash | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.sh | |
| chmod +x install.sh | |
| ./install.sh | |
| ``` | |
| **Windows (PowerShell as Administrator):** | |
| ```powershell | |
| powershell -c "irm https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.ps1 | iex" | |
| ``` | |
| Or run directly in PowerShell: | |
| ```powershell | |
| irm https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.ps1 | iex | |
| ``` | |
| Or download and run manually: | |
| ```powershell | |
| Invoke-WebRequest -Uri "https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.ps1" -OutFile install.ps1 | |
| .\install.ps1 | |
| ``` | |
| **Branch:** ${{ github.ref_name }} | |
| **Commit:** ${{ github.sha }} | |
| **Build Date:** ${{ steps.tag.outputs.build_date }} | |
| **Note:** This is a development release and may contain bugs. Use stable releases for production. | |
| **Setup:** After downloading, make the binaries executable (`chmod +x`) and ensure you have the Beeper Desktop API running. | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| cleanup-old-dev-releases: | |
| name: Cleanup Old Dev Releases | |
| runs-on: ubuntu-latest | |
| needs: create-dev-release | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| # Add explicit permissions for this job | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Delete old development releases | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const releases = await github.rest.repos.listReleases({ owner, repo }); | |
| const devReleases = releases.data.filter(release => | |
| release.tag_name.startsWith('dev-') | |
| ); | |
| const toDelete = devReleases.slice(3); | |
| console.log(`Found ${devReleases.length}/${releases.data.length} development releases, deleting ${toDelete.length} old releases.`); | |
| for (const release of toDelete) { | |
| console.log(`Deleting old dev release: ${release.tag_name}`); | |
| await github.rest.repos.deleteRelease({ owner, repo, release_id: release.id }); | |
| // Also delete the tag | |
| try { | |
| await github.rest.git.deleteRef({ owner, repo, ref: `tags/${release.tag_name}` }); | |
| } catch (error) { | |
| console.log(`Could not delete tag ${release.tag_name}: ${error.message}`); | |
| } | |
| } |