aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/semifold-ci.yaml
blob: d42b4e1cfc2d6177393f0813aa26deb1d19c76ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Semifold CI
on:
  push:
    branches: [main]

env:
  CARGO_TERM_COLOR: always
  CLICOLOR_FORCE: 1

permissions:
  id-token: write
  contents: write
  pull-requests: write

jobs:
  build-tauri:
    name: Build on ${{ matrix.name }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux
          - platform: "ubuntu-22.04"
            name: "Linux x86_64 (GNU)"
            target: "x86_64-unknown-linux-gnu"
            args: "--target x86_64-unknown-linux-gnu"
          # - platform: "ubuntu-latest"
          #   name: "Linux x86_64 (Musl)"
          #   target: "x86_64-unknown-linux-musl"
          #   args: "--target x86_64-unknown-linux-musl"
          - platform: "ubuntu-24.04-arm"
            name: "Linux arm64"
            target: "aarch64-unknown-linux-gnu"
            args: "--target aarch64-unknown-linux-gnu"
          # macOS
          - platform: "macos-latest"
            name: "macOS x86_64"
            target: "x86_64-apple-darwin"
            args: "--target x86_64-apple-darwin"
          - platform: "macos-latest"
            name: "macOS arm64"
            target: "aarch64-apple-darwin"
            args: "--target aarch64-apple-darwin"
          # Windows
          - platform: "windows-latest"
            name: "Windows x86_64 (MSVC)"
            target: "x86_64-pc-windows-msvc"
            args: "--target x86_64-pc-windows-msvc --bundles nsis"
          # - platform: "windows-latest"
          #   name: "Windows x86_64 (GNU)"
          #   target: "x86_64-pc-windows-gnu"
          #   args: "--target x86_64-pc-windows-gnu --bundles nsis"
          - platform: "windows-11-arm"
            name: "Windows arm64"
            target: "aarch64-pc-windows-msvc"
            args: "--target aarch64-pc-windows-msvc --bundles nsis"

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v6

      - name: Install Dependencies (Linux x86_64)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libfuse2

      - name: Install pnpm
        uses: pnpm/action-setup@v4

      - name: Install Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 22
          cache: "pnpm"
          cache-dependency-path: "ui/pnpm-lock.yaml"

      - name: Install Node.js Dependencies
        run: pnpm install

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Rust Cache
        uses: swatinem/rust-cache@v2
        with:
          shared-key: ${{ matrix.target }}

      - name: Setup appimagetool (Linux)
        if: startsWith(matrix.platform, 'ubuntu') && !startsWith(matrix.platform, 'macos') && !startsWith(matrix.platform, 'windows')
        run: |
          ARCH=$(uname -m)
          wget -q "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage"
          chmod +x "appimagetool-${ARCH}.AppImage"
          if command -v sudo >/dev/null 2>&1; then
            sudo mv "appimagetool-${ARCH}.AppImage" /usr/local/bin/appimagetool
          else
            mv "appimagetool-${ARCH}.AppImage" /usr/local/bin/appimagetool
          fi

      - name: Build Tauri App
        uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          args: ${{ matrix.args }}

      - name: Fix AppImage for Wayland (Linux)
        if: startsWith(matrix.platform, 'ubuntu') && !startsWith(matrix.platform, 'macos') && !startsWith(matrix.platform, 'windows')
        run: |
          # Locate the generated AppImage
          APPIMAGE=$(find bundle -name "*.AppImage" -type f | head -1)
          echo "Found AppImage: $APPIMAGE"

          if [ -n "$APPIMAGE" ]; then
            # backup original AppImage
            cp "$APPIMAGE" "${APPIMAGE}.backup"

            # extract AppImage
            "$APPIMAGE" --appimage-extract

            # Fix GTK hook, remove forced X11
            if [ -f squashfs-root/apprun-hooks/linuxdeploy-plugin-gtk.sh ]; then
              sed -i 's/^export GDK_BACKEND=x11.*$/# export GDK_BACKEND=x11  # Disabled for Wayland compatibility/' squashfs-root/apprun-hooks/linuxdeploy-plugin-gtk.sh
              echo "Successfully patched GTK hook for Wayland compatibility"
            fi

            # Repack AppImage
            appimagetool squashfs-root "$APPIMAGE"
            rm -rf squashfs-root
          fi
        working-directory: target/release

      - name: Upload Artifact (Linux)
        if: runner.os == 'Linux'
        uses: actions/upload-artifact@v6
        with:
          name: linux-${{ matrix.target }}-artifacts
          path: |
            target/${{ matrix.target }}/release/bundle/appimage/*.AppImage
            target/${{ matrix.target }}/release/bundle/deb/*.deb
            target/${{ matrix.target }}/release/bundle/appimage/*.rpm
          retention-days: 1

      - name: Upload Artifact (Windows)
        if: runner.os == 'Windows'
        uses: actions/upload-artifact@v6
        with:
          name: windows-${{ matrix.target }}-artifacts
          path: |
            target/${{ matrix.target }}/release/bundle/msi/*.msi
            target/${{ matrix.target }}/release/bundle/nsis/*.exe
          retention-days: 1

      - name: Upload Artifact (macOS)
        if: runner.os == 'macOS'
        uses: actions/upload-artifact@v6
        with:
          name: macos-${{ matrix.target }}-artifacts
          path: |
            target/${{ matrix.target }}/release/bundle/dmg/*.dmg
            target/${{ matrix.target }}/release/bundle/macos/*.app.tar.gz
          retention-days: 1

  release:
    name: Release
    runs-on: ubuntu-latest
    needs: [build-tauri]
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - name: Setup Semifold
        uses: noctisynth/setup-semifold@main
      - name: Install pnpm
        uses: pnpm/action-setup@v4
      - name: Install Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 22
          cache: "pnpm"
          cache-dependency-path: "ui/pnpm-lock.yaml"
      - name: Install Node.js Dependencies
        run: pnpm install
      - name: Download build artifacts
        uses: actions/download-artifact@v6
        with:
          path: artifacts/
          merge-multiple: true
      - name: List artifacts
        run: ls -R artifacts/
      - name: Semifold CI
        run: semifold ci
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}