notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

rust.yml (9086B)


      1 name: CI
      2 
      3 on:
      4   push:
      5     branches:
      6       - master
      7       - ci
      8   pull_request:
      9     branches:
     10       - "*"
     11 
     12 jobs:
     13   lint: 
     14     name: Rustfmt + Clippy
     15     runs-on: ubuntu-20.04
     16     steps:
     17       - uses: actions/checkout@v4
     18       - uses: dtolnay/rust-toolchain@stable
     19         with:
     20           components: rustfmt,clippy
     21       - run: |
     22           cargo fmt --all -- --check
     23           cargo clippy
     24 
     25   linux-test:
     26     name: Test (Linux)
     27     uses: ./.github/workflows/build-and-test.yml
     28     with:
     29       os: ubuntu-20.04
     30       additional-setup: |
     31         sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
     32 
     33   macos-test:
     34     name: Test (macOS)
     35     uses: ./.github/workflows/build-and-test.yml
     36     with:
     37       os: macos-latest
     38 
     39   windows-test:
     40     name: Test (Windows)
     41     uses: ./.github/workflows/build-and-test.yml
     42     with:
     43       os: windows-latest
     44 
     45   packaging:
     46     name: rpm/deb
     47     runs-on: ubuntu-20.04
     48     needs: linux-test
     49     if: github.ref_name == 'master' || github.ref_name == 'ci'
     50 
     51     strategy:
     52       fail-fast: false
     53       matrix:
     54         arch: [x86_64, aarch64]
     55 
     56     steps:
     57       # Checkout the repository
     58       - name: Checkout Code
     59         uses: actions/checkout@v4
     60 
     61       # Install Packaging Tools
     62       - name: Install Packaging Tools
     63         run: |
     64           sudo apt-get update
     65           if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
     66             sudo apt-get install -y gcc-${{ matrix.arch }}-linux-gnu g++-aarch64-linux-gnu
     67             rustup target add ${{ matrix.arch }}-unknown-linux-gnu
     68           fi
     69           cargo install cargo-generate-rpm cargo-deb
     70 
     71       - name: Build Cross (${{ matrix.arch }})
     72         if: matrix.arch != runner.arch
     73         run: cargo build --release --target=${{ matrix.arch }}-unknown-linux-gnu
     74 
     75       - name: Build Native (${{ matrix.arch }})
     76         if: matrix.arch == runner.arch
     77         run: cargo build --release
     78 
     79       - name: Build RPM (Cross)
     80         if: matrix.arch != runner.arch
     81         run: cargo generate-rpm -p crates/notedeck_chrome --target=${{ matrix.arch }}-unknown-linux-gnu
     82 
     83       - name: Build RPM
     84         if: matrix.arch == runner.arch
     85         run: cargo generate-rpm -p crates/notedeck_chrome
     86 
     87       - name: Build deb (Cross)
     88         if: matrix.arch != runner.arch
     89         run: cargo deb -p notedeck_chrome --target=${{ matrix.arch }}-unknown-linux-gnu
     90 
     91       - name: Build deb
     92         if: matrix.arch == runner.arch
     93         run: cargo deb -p notedeck_chrome
     94 
     95       - name: Upload RPM
     96         uses: actions/upload-artifact@v4
     97         if: runner.arch == matrix.arch
     98         with:
     99           name: notedeck-${{ matrix.arch }}.rpm
    100           path: target/release/generate-rpm/notedeck.rpm
    101 
    102       - name: Upload RPM (Cross)
    103         uses: actions/upload-artifact@v4
    104         if: runner.arch != matrix.arch
    105         with:
    106           name: notedeck-${{ matrix.arch }}.rpm
    107           path: target/${{ matrix.arch }}-unknown-linux-gnu/generate-rpm/*.rpm
    108 
    109       - name: Upload deb (Native)
    110         uses: actions/upload-artifact@v4
    111         if: runner.arch == matrix.arch
    112         with:
    113           name: notedeck-${{ matrix.arch }}.deb
    114           path: target/release/debian/notedeck.deb
    115 
    116       # Upload Debian Package (Cross)
    117       - name: Upload deb (Cross)
    118         uses: actions/upload-artifact@v4
    119         if: runner.arch != matrix.arch
    120         with:
    121           name: notedeck-${{ matrix.arch }}.deb
    122           path: target/${{ matrix.arch }}-unknown-linux-gnu/debian/*.deb
    123 
    124   macos-dmg:
    125     name: macOS dmg
    126     runs-on: macos-latest
    127     needs: macos-test
    128     if: github.ref_name == 'master' || github.ref_name == 'ci'
    129     env:
    130       NOTEDECK_APPLE_RELEASE_CERT_ID: ${{ secrets.NOTEDECK_APPLE_RELEASE_CERT_ID }}
    131       NOTEDECK_RELEASE_APPLE_ID: ${{ secrets.NOTEDECK_RELEASE_APPLE_ID }}
    132       NOTEDECK_APPLE_APP_SPECIFIC_PW: ${{ secrets.NOTEDECK_APPLE_APP_SPECIFIC_PW }}
    133       NOTEDECK_APPLE_TEAM_ID: ${{ secrets.NOTEDECK_APPLE_TEAM_ID }}
    134 
    135     strategy:
    136       fail-fast: false
    137       matrix:
    138         arch: [x86_64, aarch64]
    139 
    140     steps:
    141       # Checkout the repository
    142       - name: Checkout Code
    143         uses: actions/checkout@v4
    144 
    145       - name: Install Required Tools
    146         run: |
    147           brew install create-dmg
    148           cargo install cargo-bundle
    149           rustup target add ${{ matrix.arch }}-apple-darwin
    150 
    151       - name: Import apple codesign cert
    152         uses: apple-actions/import-codesign-certs@v3
    153         with: 
    154           p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
    155           p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
    156 
    157       - name: Rust cache
    158         uses: Swatinem/rust-cache@v2
    159 
    160       - name: Run macOS DMG Build Script
    161         run: ARCH=${{ matrix.arch }} ./scripts/macos_build.sh
    162 
    163       - name: Upload DMG Artifact
    164         uses: actions/upload-artifact@v4
    165         with:
    166           name: notedeck-${{ matrix.arch }}.dmg
    167           path: packages/notedeck-${{ matrix.arch }}.dmg
    168 
    169   windows-installer:
    170     name: Windows Installer
    171     runs-on: windows-latest
    172     needs: windows-test
    173     if: github.ref_name == 'master' || github.ref_name == 'ci'
    174     strategy:
    175       fail-fast: false
    176       matrix:
    177         arch: [x86_64, aarch64]
    178 
    179     steps:
    180       # Checkout the repository
    181       - name: Checkout Code
    182         uses: actions/checkout@v4
    183 
    184       # Build cache
    185       - name: Rust cache
    186         uses: Swatinem/rust-cache@v2
    187 
    188       # Build
    189       - name: Build (Native Only)
    190         run: cargo build --release
    191 
    192       # Create packages directory
    193       - name: Create packages directory
    194         run: mkdir packages
    195 
    196       # Install Inno Setup
    197       - name: Install Inno Setup
    198         run: choco install innosetup --no-progress --yes
    199 
    200       # Set up Rust toolchain
    201       - name: Install Rust toolchain
    202         run: rustup target add ${{ matrix.arch }}-pc-windows-msvc
    203 
    204       # Build
    205       - name: Build
    206         shell: pwsh
    207         run: |
    208           $target = "${{ matrix.arch }}-pc-windows-msvc"
    209           Write-Output "Building for target: $target"
    210           cargo build --release --target=$target
    211 
    212       # Generate ISS Script
    213       - name: Generate Inno Setup Script
    214         shell: pwsh
    215         run: |
    216           $arch = "${{ matrix.arch }}"
    217           $issContent = @"
    218           [Setup]
    219           AppName=Damus Notedeck
    220           AppVersion=0.1
    221           DefaultDirName={pf}\Notedeck
    222           DefaultGroupName=Damus Notedeck
    223           OutputDir=..\packages\$arch
    224           OutputBaseFilename=DamusNotedeckInstaller
    225           Compression=lzma
    226           SolidCompression=yes
    227 
    228           [Files]
    229           Source: "..\target\$arch-pc-windows-msvc\release\notedeck.exe"; DestDir: "{app}"; Flags: ignoreversion
    230 
    231           [Icons]
    232           Name: "{group}\Damus Notedeck"; Filename: "{app}\notedeck.exe"
    233 
    234           [Run]
    235           Filename: "{app}\notedeck.exe"; Description: "Launch Damus Notedeck"; Flags: nowait postinstall skipifsilent
    236           "@
    237           Set-Content -Path "scripts/windows-installer-$arch.iss" -Value $issContent
    238 
    239       # Build Installer
    240       - name: Run Inno Setup Script
    241         run: |
    242           & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "scripts\windows-installer-${{ matrix.arch }}.iss"
    243 
    244       # Move output
    245       - name: Move Inno Script outputs to architecture-specific folder
    246         run: |
    247           New-Item -ItemType Directory -Force -Path packages\${{ matrix.arch }}
    248           Move-Item -Path packages\${{ matrix.arch }}\DamusNotedeckInstaller.exe -Destination packages\${{ matrix.arch }}\DamusNotedeckInstaller.exe
    249       # Upload the installer as an artifact
    250       - name: Upload Installer
    251         uses: actions/upload-artifact@v4
    252         with:
    253           name: DamusNotedeckInstaller-${{ matrix.arch }}.exe
    254           path: packages\${{ matrix.arch }}\DamusNotedeckInstaller.exe
    255 
    256   upload-artifacts:
    257     name: Upload Artifacts to Server
    258     runs-on: ubuntu-20.04
    259     needs: [packaging, macos-dmg, windows-installer]
    260     if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/ci'
    261 
    262     steps:
    263       - name: Download all Artifacts
    264         uses: actions/download-artifact@v4
    265 
    266       - name: Setup SSH and Upload
    267         run: |
    268           eval "$(ssh-agent -s)"
    269           mkdir -p ~/.ssh
    270           chmod 700 ~/.ssh
    271           echo "${{ secrets.DEPLOY_SFTP_KEY }}" | tr -d '\r' | ssh-add -
    272           echo "${{ secrets.DEPLOY_IP }} ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEN65pj1cNMqlf96jZLr1i9+mnHIN4jjRPPTDix6sRnt" >> ~/.ssh/known_hosts
    273           ls -la /home/runner/work/notedeck/notedeck/notedeck-x86_64.rpm
    274           export ARTIFACTS=/home/runner/work/notedeck/notedeck
    275           sftp ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_IP }} <<EOF
    276           cd upload/artifacts
    277           put $ARTIFACTS/notedeck-x86_64.rpm/*
    278           put $ARTIFACTS/notedeck-x86_64.deb/*
    279           put $ARTIFACTS/notedeck-x86_64.dmg/*
    280           put $ARTIFACTS/notedeck-aarch64.rpm/*
    281           put $ARTIFACTS/notedeck-aarch64.deb/*
    282           put $ARTIFACTS/notedeck-aarch64.dmg/*
    283           put $ARTIFACTS/DamusNotedeckInstaller-x86_64.exe/*
    284           put $ARTIFACTS/DamusNotedeckInstaller-aarch64.exe/*
    285           bye
    286           EOF
    287