|
| 1 | +# Copyright 2025 Signal Messenger, LLC |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-only |
| 3 | + |
| 4 | +name: Publish |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + dry_run: |
| 9 | + description: "Just build, don't publish" |
| 10 | + default: false |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + npm_tag: |
| 14 | + description: 'NPM tag' |
| 15 | + required: true |
| 16 | + default: 'latest' |
| 17 | + |
| 18 | +jobs: |
| 19 | + prebuild: |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + os: [windows-latest, macos-latest] |
| 23 | + include: |
| 24 | + - os: macos-latest |
| 25 | + target: arm64 |
| 26 | + cross-target: x64 |
| 27 | + rust-cross-target: x86_64-apple-darwin |
| 28 | + - os: windows-latest |
| 29 | + target: x64 |
| 30 | + cross-target: arm64 |
| 31 | + rust-cross-target: aarch64-pc-windows-msvc |
| 32 | + |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + timeout-minutes: 30 |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 39 | + - name: Setup pnpm |
| 40 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 41 | + with: |
| 42 | + version: 10.3.0 |
| 43 | + |
| 44 | + - name: Get Node version from .nvmrc |
| 45 | + id: get-nvm-version |
| 46 | + shell: bash |
| 47 | + run: echo "node-version=$(cat .nvmrc)" >> $GITHUB_OUTPUT |
| 48 | + |
| 49 | + - name: Setup node.js |
| 50 | + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 51 | + with: |
| 52 | + node-version-file: '.nvmrc' |
| 53 | + |
| 54 | + - name: Install node_modules |
| 55 | + run: pnpm install --frozen-lockfile |
| 56 | + |
| 57 | + - run: rustup toolchain install $(cat rust-toolchain) --profile minimal --target ${{ matrix.rust-cross-target }} |
| 58 | + |
| 59 | + - name: Install dump_syms |
| 60 | + run: cargo install dump_syms --no-default-features --features cli |
| 61 | + |
| 62 | + - name: Prebuild ${{ matrix.target }} |
| 63 | + run: | |
| 64 | + pnpm prebuildify --target '${{ steps.get-nvm-version.outputs.node-version }}' --arch ${{ matrix.target }} |
| 65 | + - name: Prebuild ${{ matrix.cross-target }} |
| 66 | + run: pnpm prebuildify --target '${{ steps.get-nvm-version.outputs.node-version }}' --arch ${{ matrix.cross-target }} |
| 67 | + |
| 68 | + - name: Upload artifacts |
| 69 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 70 | + with: |
| 71 | + name: sqlcipher-${{matrix.os}} |
| 72 | + path: prebuilds/* |
| 73 | + |
| 74 | + prebuild_linux: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + timeout-minutes: 30 |
| 77 | + |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 80 | + - name: Build in docker container |
| 81 | + run: ./docker-prebuildify.sh |
| 82 | + |
| 83 | + - name: Upload artifacts |
| 84 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 85 | + with: |
| 86 | + name: sqlcipher-linux-latest |
| 87 | + path: prebuilds/* |
| 88 | + |
| 89 | + publish: |
| 90 | + name: Publish |
| 91 | + |
| 92 | + permissions: |
| 93 | + # Needed for ncipollo/release-action. |
| 94 | + contents: 'write' |
| 95 | + |
| 96 | + runs-on: ubuntu-latest |
| 97 | + |
| 98 | + needs: [prebuild, prebuild_linux] |
| 99 | + |
| 100 | + timeout-minutes: 45 |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Checkout |
| 104 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 105 | + |
| 106 | + - name: Setup pnpm |
| 107 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 108 | + with: |
| 109 | + version: 10.3.0 |
| 110 | + - name: Setup node.js |
| 111 | + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 112 | + with: |
| 113 | + node-version-file: '.nvmrc' |
| 114 | + registry-url: 'https://registry.npmjs.org/' |
| 115 | + |
| 116 | + - name: Download built libraries |
| 117 | + uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.19.1 |
| 118 | + with: |
| 119 | + pattern: sqlcipher-* |
| 120 | + path: prebuilds |
| 121 | + merge-multiple: true |
| 122 | + |
| 123 | + - name: Install node_modules |
| 124 | + run: pnpm install --frozen-lockfile |
| 125 | + |
| 126 | + - name: Build |
| 127 | + run: pnpm build |
| 128 | + |
| 129 | + - name: Lint |
| 130 | + run: pnpm lint |
| 131 | + |
| 132 | + - run: pnpm test |
| 133 | + env: |
| 134 | + PREBUILDS_ONLY: 1 |
| 135 | + |
| 136 | + - name: Publish |
| 137 | + run: pnpm publish --tag '${{ github.event.inputs.npm_tag }}' --access public --no-git-checks ${{ inputs.dry_run && '--dry-run' || ''}} |
| 138 | + env: |
| 139 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 140 | + |
| 141 | + - name: Rename symbols |
| 142 | + run: | |
| 143 | + mv prebuilds/darwin-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_darwin_arm64.sym |
| 144 | + mv prebuilds/darwin-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_darwin_x64.sym |
| 145 | + mv prebuilds/linux-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_linux_arm64.sym |
| 146 | + mv prebuilds/linux-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_linux_x64.sym |
| 147 | + mv prebuilds/win32-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_win32_arm64.sym |
| 148 | + mv prebuilds/win32-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_win32_x64.sym |
| 149 | +
|
| 150 | + # This step is expected to fail if not run on a tag. |
| 151 | + - name: Upload debug info to release |
| 152 | + uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0 |
| 153 | + if: ${{ !inputs.dry_run }} |
| 154 | + with: |
| 155 | + allowUpdates: true |
| 156 | + artifactErrorsFailBuild: true |
| 157 | + artifacts: prebuilds/node_sqlcipher_*.sym |
0 commit comments