|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version to release (e.g., 1.0.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +env: |
| 12 | + DEBUG: napi:* |
| 13 | + APP_NAME: atlas-local |
| 14 | + MACOSX_DEPLOYMENT_TARGET: '10.13' |
| 15 | + |
| 16 | +jobs: |
| 17 | + update-version: |
| 18 | + name: Update Version |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + version: ${{ steps.version.outputs.version }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v5 |
| 24 | + with: |
| 25 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + - name: Setup node |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: 22 |
| 30 | + cache: yarn |
| 31 | + - name: Install Rust toolchain |
| 32 | + uses: dtolnay/rust-toolchain@stable |
| 33 | + with: |
| 34 | + toolchain: stable |
| 35 | + targets: x86_64-unknown-linux-gnu |
| 36 | + - name: Install dependencies |
| 37 | + run: yarn install |
| 38 | + - name: Update package.json version |
| 39 | + run: | |
| 40 | + npm version ${{ github.event.inputs.version }} --no-git-tag-version |
| 41 | + - name: Update Cargo.toml version |
| 42 | + run: | |
| 43 | + sed -i 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' Cargo.toml |
| 44 | + - name: Build to update generated files |
| 45 | + run: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross |
| 46 | + - name: Commit version changes |
| 47 | + run: | |
| 48 | + git config --local user.email "[email protected]" |
| 49 | + git config --local user.name "GitHub Action" |
| 50 | + git add package.json Cargo.toml index.js index.d.ts |
| 51 | + git commit -m "${{ github.event.inputs.version }}" |
| 52 | + git push |
| 53 | + - name: Set version output |
| 54 | + id: version |
| 55 | + run: echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT |
| 56 | + |
| 57 | + build: |
| 58 | + name: Build Release |
| 59 | + needs: update-version |
| 60 | + strategy: |
| 61 | + fail-fast: false |
| 62 | + matrix: |
| 63 | + settings: |
| 64 | + - host: macos-latest |
| 65 | + target: x86_64-apple-darwin |
| 66 | + build: yarn build --target x86_64-apple-darwin |
| 67 | + - host: windows-latest |
| 68 | + build: yarn build --target x86_64-pc-windows-msvc |
| 69 | + target: x86_64-pc-windows-msvc |
| 70 | + - host: ubuntu-latest |
| 71 | + target: x86_64-unknown-linux-gnu |
| 72 | + build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross |
| 73 | + - host: macos-latest |
| 74 | + target: aarch64-apple-darwin |
| 75 | + build: yarn build --target aarch64-apple-darwin |
| 76 | + - host: ubuntu-latest |
| 77 | + target: aarch64-unknown-linux-gnu |
| 78 | + build: yarn build --target aarch64-unknown-linux-gnu --use-napi-cross |
| 79 | + runs-on: ${{ matrix.settings.host }} |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v5 |
| 82 | + with: |
| 83 | + ref: main |
| 84 | + - name: Setup node |
| 85 | + uses: actions/setup-node@v4 |
| 86 | + with: |
| 87 | + node-version: 22 |
| 88 | + cache: yarn |
| 89 | + - name: Install Rust toolchain |
| 90 | + uses: dtolnay/rust-toolchain@stable |
| 91 | + with: |
| 92 | + toolchain: stable |
| 93 | + targets: ${{ matrix.settings.target }} |
| 94 | + - name: Cache cargo |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: | |
| 98 | + ~/.cargo/registry/index/ |
| 99 | + ~/.cargo/registry/cache/ |
| 100 | + ~/.cargo/git/db/ |
| 101 | + ~/.napi-rs |
| 102 | + .cargo-cache |
| 103 | + target/ |
| 104 | + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} |
| 105 | + - name: Install dependencies |
| 106 | + run: yarn install |
| 107 | + - name: Build |
| 108 | + run: ${{ matrix.settings.build }} |
| 109 | + shell: bash |
| 110 | + - name: Upload artifact |
| 111 | + uses: actions/upload-artifact@v4 |
| 112 | + with: |
| 113 | + name: bindings-${{ matrix.settings.target }} |
| 114 | + path: | |
| 115 | + ${{ env.APP_NAME }}.*.node |
| 116 | + ${{ env.APP_NAME }}.*.wasm |
| 117 | + if-no-files-found: error |
| 118 | + |
| 119 | + publish: |
| 120 | + name: Publish Release |
| 121 | + runs-on: ubuntu-latest |
| 122 | + permissions: |
| 123 | + contents: write |
| 124 | + id-token: write |
| 125 | + needs: [update-version, build] |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@v5 |
| 128 | + with: |
| 129 | + ref: main |
| 130 | + - name: Setup node |
| 131 | + uses: actions/setup-node@v4 |
| 132 | + with: |
| 133 | + node-version: 22 |
| 134 | + cache: yarn |
| 135 | + - name: Install dependencies |
| 136 | + run: yarn install |
| 137 | + - name: Create npm dirs |
| 138 | + run: yarn napi create-npm-dirs |
| 139 | + - name: Download all artifacts |
| 140 | + uses: actions/download-artifact@v5 |
| 141 | + with: |
| 142 | + path: artifacts |
| 143 | + - name: Move artifacts |
| 144 | + run: yarn artifacts |
| 145 | + - name: List packages |
| 146 | + run: ls -R ./npm |
| 147 | + shell: bash |
| 148 | + - name: Create GitHub Release |
| 149 | + uses: actions/create-release@v1 |
| 150 | + env: |
| 151 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 152 | + with: |
| 153 | + tag_name: v${{ needs.update-version.outputs.version }} |
| 154 | + release_name: Release v${{ needs.update-version.outputs.version }} |
| 155 | + draft: false |
| 156 | + prerelease: false |
| 157 | + - name: Publish to NPM |
| 158 | + run: | |
| 159 | + npm config set provenance true |
| 160 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 161 | + npm publish --access public |
| 162 | + env: |
| 163 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments