|
| 1 | +name: release conductor to npm |
| 2 | +env: |
| 3 | + DEBUG: napi:* |
| 4 | + APP_NAME: lib |
| 5 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + id-token: write |
| 9 | +'on': |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + tags-ignore: |
| 14 | + - '**' |
| 15 | + paths-ignore: |
| 16 | + - '**/*.md' |
| 17 | + - LICENSE |
| 18 | + - '**/*.gitignore' |
| 19 | + - .editorconfig |
| 20 | + - docs/** |
| 21 | + pull_request: null |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + settings: |
| 28 | + - host: macos-latest |
| 29 | + target: x86_64-apple-darwin |
| 30 | + build: | |
| 31 | + yarn build |
| 32 | + strip -x *.node |
| 33 | + - host: ubuntu-latest |
| 34 | + target: x86_64-unknown-linux-gnu |
| 35 | + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 36 | + build: |- |
| 37 | + set -e && |
| 38 | + yarn build --target x86_64-unknown-linux-gnu && |
| 39 | + strip *.node |
| 40 | + name: stable - ${{ matrix.settings.target }} - node@18 |
| 41 | + runs-on: ${{ matrix.settings.host }} |
| 42 | + defaults: |
| 43 | + run: |
| 44 | + working-directory: libs/napi |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - name: Setup node |
| 48 | + uses: actions/setup-node@v4 |
| 49 | + if: ${{ !matrix.settings.docker }} |
| 50 | + with: |
| 51 | + node-version: 18 |
| 52 | + - name: Install |
| 53 | + uses: dtolnay/rust-toolchain@stable |
| 54 | + if: ${{ !matrix.settings.docker }} |
| 55 | + with: |
| 56 | + toolchain: stable |
| 57 | + targets: ${{ matrix.settings.target }} |
| 58 | + - name: Cache cargo |
| 59 | + uses: actions/cache@v3 |
| 60 | + with: |
| 61 | + path: | |
| 62 | + ~/.cargo/registry/index/ |
| 63 | + ~/.cargo/registry/cache/ |
| 64 | + ~/.cargo/git/db/ |
| 65 | + .cargo-cache |
| 66 | + target/ |
| 67 | + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} |
| 68 | + - uses: goto-bus-stop/setup-zig@v2 |
| 69 | + if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} |
| 70 | + with: |
| 71 | + version: 0.11.0 |
| 72 | + - name: Setup toolchain |
| 73 | + run: ${{ matrix.settings.setup }} |
| 74 | + if: ${{ matrix.settings.setup }} |
| 75 | + shell: bash |
| 76 | + - name: Install dependencies |
| 77 | + run: yarn install |
| 78 | + - name: Build in docker |
| 79 | + uses: addnab/docker-run-action@v3 |
| 80 | + if: ${{ matrix.settings.docker }} |
| 81 | + with: |
| 82 | + image: ${{ matrix.settings.docker }} |
| 83 | + options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build/libs/napi' |
| 84 | + run: ${{ matrix.settings.build }} |
| 85 | + - name: Build |
| 86 | + run: ${{ matrix.settings.build }} |
| 87 | + if: ${{ !matrix.settings.docker }} |
| 88 | + shell: bash |
| 89 | + - name: Upload artifact |
| 90 | + uses: actions/upload-artifact@v3 |
| 91 | + with: |
| 92 | + name: bindings-${{ matrix.settings.target }} |
| 93 | + path: libs/napi/${{ env.APP_NAME }}.*.node |
| 94 | + if-no-files-found: error |
| 95 | + |
| 96 | + publish: |
| 97 | + name: Publish |
| 98 | + runs-on: ubuntu-latest |
| 99 | + defaults: |
| 100 | + run: |
| 101 | + working-directory: libs/napi |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + - name: Setup node |
| 105 | + uses: actions/setup-node@v4 |
| 106 | + with: |
| 107 | + node-version: 18 |
| 108 | + |
| 109 | + - name: Install dependencies |
| 110 | + run: yarn install |
| 111 | + - name: Download all artifacts |
| 112 | + uses: actions/download-artifact@v3 |
| 113 | + with: |
| 114 | + path: artifacts |
| 115 | + - name: Move artifacts |
| 116 | + run: yarn artifacts |
| 117 | + - name: List packages |
| 118 | + run: ls -R ./npm |
| 119 | + shell: bash |
| 120 | + - name: Publish |
| 121 | + run: | |
| 122 | + npm config set provenance true |
| 123 | + if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; |
| 124 | + then |
| 125 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 126 | + npm publish --access public |
| 127 | + elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; |
| 128 | + then |
| 129 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 130 | + npm publish --tag next --access public |
| 131 | + else |
| 132 | + echo "Not a release, skipping publish" |
| 133 | + fi |
| 134 | + env: |
| 135 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 136 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments