|
| 1 | +name: Build extension zip |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [typescript] |
| 6 | + tags: ["v*"] |
| 7 | + pull_request: |
| 8 | + branches: [typescript] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Read by default. The release job below opts into write. |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +env: |
| 16 | + UUID: hanabi-extension@jeffshee.github.io |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install system dependencies |
| 26 | + run: | |
| 27 | + sudo apt-get update |
| 28 | + sudo apt-get install -y meson ninja-build gettext libglib2.0-bin |
| 29 | +
|
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: 20 |
| 34 | + cache: npm |
| 35 | + |
| 36 | + - name: Install npm dependencies |
| 37 | + run: npm ci |
| 38 | + |
| 39 | + - name: Build TypeScript sources |
| 40 | + run: npm run build |
| 41 | + |
| 42 | + - name: Assemble extension into a staging prefix |
| 43 | + run: | |
| 44 | + meson setup .build-ci --prefix=/usr |
| 45 | + DESTDIR="${GITHUB_WORKSPACE}/staging" meson install -C .build-ci |
| 46 | +
|
| 47 | + - name: Package zip installable with `gnome-extensions install` |
| 48 | + run: | |
| 49 | + ext="${GITHUB_WORKSPACE}/staging/usr/share/gnome-shell/extensions/${UUID}" |
| 50 | + # meson installs the gschema XML under the glib prefix; an installable |
| 51 | + # zip needs the schema (compiled) inside the extension's own schemas/ dir. |
| 52 | + mkdir -p "${ext}/schemas" |
| 53 | + cp "${GITHUB_WORKSPACE}"/staging/usr/share/glib-2.0/schemas/*.gschema.xml "${ext}/schemas/" |
| 54 | + glib-compile-schemas "${ext}/schemas/" |
| 55 | + mkdir -p "${GITHUB_WORKSPACE}/dist" |
| 56 | + ( cd "${ext}" && zip -qr "${GITHUB_WORKSPACE}/dist/${UUID}.shell-extension.zip" . ) |
| 57 | + echo "Packaged:" |
| 58 | + unzip -l "${GITHUB_WORKSPACE}/dist/${UUID}.shell-extension.zip" |
| 59 | +
|
| 60 | + - name: Upload zip artifact |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: ${{ env.UUID }}.shell-extension |
| 64 | + path: dist/*.shell-extension.zip |
| 65 | + if-no-files-found: error |
| 66 | + |
| 67 | + # Separate job so write permission is granted only when publishing a release. |
| 68 | + release: |
| 69 | + needs: build |
| 70 | + if: startsWith(github.ref, 'refs/tags/v') |
| 71 | + runs-on: ubuntu-latest |
| 72 | + permissions: |
| 73 | + contents: write |
| 74 | + steps: |
| 75 | + - name: Download zip artifact |
| 76 | + uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + name: ${{ env.UUID }}.shell-extension |
| 79 | + path: dist |
| 80 | + |
| 81 | + - name: Attach zip to GitHub Release |
| 82 | + env: |
| 83 | + GH_TOKEN: ${{ github.token }} |
| 84 | + run: gh release create "${GITHUB_REF_NAME}" dist/*.shell-extension.zip --generate-notes |
0 commit comments