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