rust.yml (7818B)
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-latest 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-latest 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-latest 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: Rust cache 72 uses: Swatinem/rust-cache@v2 73 74 - name: Build Cross (${{ matrix.arch }}) 75 if: matrix.arch != runner.arch 76 run: cargo build --release --target=${{ matrix.arch }}-unknown-linux-gnu 77 78 - name: Build Native (${{ matrix.arch }}) 79 if: matrix.arch == runner.arch 80 run: cargo build --release 81 82 - name: Build RPM (Cross) 83 if: matrix.arch != runner.arch 84 run: cargo generate-rpm -p crates/notedeck_chrome --target=${{ matrix.arch }}-unknown-linux-gnu 85 86 - name: Build RPM 87 if: matrix.arch == runner.arch 88 run: cargo generate-rpm -p crates/notedeck_chrome 89 90 - name: Build deb (Cross) 91 if: matrix.arch != runner.arch 92 run: cargo deb -p notedeck_chrome --target=${{ matrix.arch }}-unknown-linux-gnu 93 94 - name: Build deb 95 if: matrix.arch == runner.arch 96 run: cargo deb -p notedeck_chrome 97 98 - name: Upload RPM 99 uses: actions/upload-artifact@v4 100 if: runner.arch == matrix.arch 101 with: 102 name: notedeck-${{ matrix.arch }}.rpm 103 path: target/release/generate-rpm/notedeck.rpm 104 105 - name: Upload RPM (Cross) 106 uses: actions/upload-artifact@v4 107 if: runner.arch != matrix.arch 108 with: 109 name: notedeck-${{ matrix.arch }}.rpm 110 path: target/${{ matrix.arch }}-unknown-linux-gnu/generate-rpm/*.rpm 111 112 - name: Upload deb (Native) 113 uses: actions/upload-artifact@v4 114 if: runner.arch == matrix.arch 115 with: 116 name: notedeck-${{ matrix.arch }}.deb 117 path: target/release/debian/notedeck.deb 118 119 # Upload Debian Package (Cross) 120 - name: Upload deb (Cross) 121 uses: actions/upload-artifact@v4 122 if: runner.arch != matrix.arch 123 with: 124 name: notedeck-${{ matrix.arch }}.deb 125 path: target/${{ matrix.arch }}-unknown-linux-gnu/debian/*.deb 126 127 macos-dmg: 128 name: macOS dmg 129 runs-on: macos-latest 130 needs: macos-test 131 if: github.ref_name == 'master' || github.ref_name == 'ci' 132 env: 133 NOTEDECK_APPLE_RELEASE_CERT_ID: ${{ secrets.NOTEDECK_APPLE_RELEASE_CERT_ID }} 134 NOTEDECK_RELEASE_APPLE_ID: ${{ secrets.NOTEDECK_RELEASE_APPLE_ID }} 135 NOTEDECK_APPLE_APP_SPECIFIC_PW: ${{ secrets.NOTEDECK_APPLE_APP_SPECIFIC_PW }} 136 NOTEDECK_APPLE_TEAM_ID: ${{ secrets.NOTEDECK_APPLE_TEAM_ID }} 137 138 strategy: 139 fail-fast: false 140 matrix: 141 arch: [x86_64, aarch64] 142 143 steps: 144 # Checkout the repository 145 - name: Checkout Code 146 uses: actions/checkout@v4 147 148 - name: Install Required Tools 149 run: | 150 brew install create-dmg 151 cargo install cargo-bundle 152 rustup target add ${{ matrix.arch }}-apple-darwin 153 154 - name: Import apple codesign cert 155 uses: apple-actions/import-codesign-certs@v3 156 with: 157 p12-file-base64: ${{ secrets.CERTIFICATES_P12 }} 158 p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} 159 160 - name: Rust cache 161 uses: Swatinem/rust-cache@v2 162 163 - name: Run macOS DMG Build Script 164 run: ARCH=${{ matrix.arch }} ./scripts/macos_build.sh 165 166 - name: Upload DMG Artifact 167 uses: actions/upload-artifact@v4 168 with: 169 name: notedeck-${{ matrix.arch }}.dmg 170 path: packages/notedeck-${{ matrix.arch }}.dmg 171 172 windows-installer: 173 name: Windows Installer 174 runs-on: windows-latest 175 needs: windows-test 176 if: github.ref_name == 'master' || github.ref_name == 'ci' 177 strategy: 178 fail-fast: false 179 matrix: 180 arch: [x86_64, aarch64] 181 182 steps: 183 # Checkout the repository 184 - name: Checkout Code 185 uses: actions/checkout@v4 186 187 # Build cache 188 - name: Rust cache 189 uses: Swatinem/rust-cache@v2 190 191 # Build 192 - name: Build (Native Only) 193 run: cargo build --release 194 195 # Create packages directory 196 - name: Create packages directory 197 run: mkdir packages 198 199 # Install Inno Setup 200 - name: Install Inno Setup 201 run: choco install innosetup --no-progress --yes 202 203 # Set up Rust toolchain 204 - name: Install Rust toolchain 205 run: rustup target add ${{ matrix.arch }}-pc-windows-msvc 206 207 # Build 208 - name: Build 209 shell: pwsh 210 run: | 211 $target = "${{ matrix.arch }}-pc-windows-msvc" 212 Write-Output "Building for target: $target" 213 cargo build --release --target=$target 214 215 # Generate ISS Script 216 - name: Generate Inno Setup Script 217 shell: pwsh 218 run: | 219 $arch = "${{ matrix.arch }}" 220 $issContent = @" 221 [Setup] 222 AppName=Damus Notedeck 223 AppVersion=0.1 224 DefaultDirName={pf}\Notedeck 225 DefaultGroupName=Damus Notedeck 226 OutputDir=..\packages\$arch 227 OutputBaseFilename=DamusNotedeckInstaller 228 Compression=lzma 229 SolidCompression=yes 230 231 [Files] 232 Source: "..\target\$arch-pc-windows-msvc\release\notedeck.exe"; DestDir: "{app}"; Flags: ignoreversion 233 234 [Icons] 235 Name: "{group}\Damus Notedeck"; Filename: "{app}\notedeck.exe" 236 237 [Run] 238 Filename: "{app}\notedeck.exe"; Description: "Launch Damus Notedeck"; Flags: nowait postinstall skipifsilent 239 "@ 240 Set-Content -Path "scripts/windows-installer-$arch.iss" -Value $issContent 241 242 # Build Installer 243 - name: Run Inno Setup Script 244 run: | 245 & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "scripts\windows-installer-${{ matrix.arch }}.iss" 246 247 # Move output 248 - name: Move Inno Script outputs to architecture-specific folder 249 run: | 250 New-Item -ItemType Directory -Force -Path packages\${{ matrix.arch }} 251 Move-Item -Path packages\${{ matrix.arch }}\DamusNotedeckInstaller.exe -Destination packages\${{ matrix.arch }}\DamusNotedeckInstaller.exe 252 # Upload the installer as an artifact 253 - name: Upload Installer 254 uses: actions/upload-artifact@v4 255 with: 256 name: DamusNotedeckInstaller-${{ matrix.arch }}.exe 257 path: packages\${{ matrix.arch }}\DamusNotedeckInstaller.exe 258