ci: fix homebrew tap update #28
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main, master] | |
| jobs: | |
| analyze-test: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.38.9' | |
| cache: true | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Run code generation | |
| run: dart run build_runner build --delete-conflicting-outputs | |
| - name: Analyze code | |
| run: flutter analyze --no-fatal-infos | |
| - name: Run tests | |
| run: flutter test | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| needs: analyze-test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.38.9' | |
| cache: true | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Run code generation | |
| run: dart run build_runner build --delete-conflicting-outputs | |
| - name: Build Linux | |
| run: | | |
| flutter build linux --release | |
| cd build/linux/x64/release | |
| zip -r lbpSSH-linux-x64.zip bundle | |
| - name: Upload Linux build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: build/linux/x64/release/lbpSSH-linux-x64.zip | |
| build-windows: | |
| runs-on: windows-latest | |
| needs: analyze-test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.38.9' | |
| cache: true | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Run code generation | |
| run: dart run build_runner build --delete-conflicting-outputs | |
| - name: Build Windows | |
| run: | | |
| flutter build windows --release | |
| Compress-Archive -Path build/windows/x64/runner\ -DestinationPath build/windows/x64/lbpSSH-windows-x64.zip | |
| - name: Upload Windows build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: build/windows/x64/lbpSSH-windows-x64.zip | |
| build-macos: | |
| runs-on: macos-latest | |
| needs: analyze-test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.38.9' | |
| cache: true | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Run code generation | |
| run: dart run build_runner build --delete-conflicting-outputs | |
| - name: Build macOS | |
| run: | | |
| flutter build macos --release --no-tree-shake-icons | |
| cd build/macos/Build/Products/Release | |
| zip -r lbpSSH-macos-universal.zip lbpSSH.app | |
| - name: Upload macOS build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: build/macos/Build/Products/Release/lbpSSH-macos-universal.zip | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows, build-macos] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Download Linux build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: releases/ | |
| - name: Download Windows build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: releases/ | |
| - name: Download macOS build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: releases/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.VERSION }} | |
| name: Release ${{ steps.version.outputs.VERSION }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| releases/**/* | |
| body: | | |
| ## Changes | |
| See [CHANGELOG.md](./CHANGELOG.md) for details. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update Homebrew Tap | |
| env: | |
| VERSION: ${{ steps.version.outputs.VERSION }} | |
| HOMEBREW_TAP_REPO: ${{ secrets.HOMEBREW_TAP_REPO }} | |
| HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| run: | | |
| if [ -z "$HOMEBREW_TAP_REPO" ]; then | |
| echo "HOMEBREW_TAP_REPO not set, skipping" | |
| exit 0 | |
| fi | |
| # Install coreutils for sha256sum | |
| sudo apt-get update | |
| sudo apt-get install -y coreutils | |
| # Clone tap repo | |
| git clone "https://github.com/$HOMEBREW_TAP_REPO.git" /tmp/homebrew-tap | |
| cd /tmp/homebrew-tap | |
| # Calculate sha256 for macOS zip | |
| SHA256=$(sha256sum "../releases/lbpSSH-macos-universal.zip" | cut -d' ' -f1) | |
| # Update cask file | |
| sed -i "s/version \".*\"/version \"$VERSION\"/" Casks/lbpssh.rb | |
| sed -i "s/sha256 :no_check/sha256 \"$SHA256\"/" Casks/lbpssh.rb | |
| # Commit and push | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add Casks/lbpssh.rb | |
| git commit -m "Update lbpssh to $VERSION" | |
| git push "https://$HOMEBREW_TOKEN@github.com/$HOMEBREW_TAP_REPO.git" | |
| release-draft: | |
| runs-on: ubuntu-latest | |
| needs: [build-linux, build-windows, build-macos] | |
| if: github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "RUN_NUMBER=${{ github.run_number }}" >> $GITHUB_OUTPUT | |
| - name: Download builds | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: releases/ | |
| merge-multiple: true | |
| - name: Create Pre-release Draft | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.VERSION }}-${{ steps.version.outputs.RUN_NUMBER }} | |
| name: Pre-release ${{ steps.version.outputs.VERSION }} (Build ${{ steps.version.outputs.RUN_NUMBER }}) | |
| draft: true | |
| prerelease: true | |
| files: | | |
| releases/**/* | |
| body: | | |
| ## Pre-release | |
| This is a pre-release build for testing purposes. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |