|
20 | 20 | outputs: |
21 | 21 | version_number: ${{ steps.release_metadata.outputs.version_number }} |
22 | 22 | changelog: ${{ steps.release_metadata.outputs.changelog }} |
| 23 | + release_notes: ${{ steps.release_metadata.outputs.release_notes }} |
23 | 24 | steps: |
24 | 25 | - uses: apify/workflows/git-cliff-release@main |
25 | 26 | name: Prepare release metadata |
|
45 | 46 | runs-on: ubuntu-latest |
46 | 47 | outputs: |
47 | 48 | changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }} |
| 49 | + pre_release_version: ${{ steps.get-pre-release-version.outputs.pre_release_version }} |
| 50 | + |
48 | 51 | steps: |
49 | 52 | - name: Checkout repository |
50 | 53 | uses: actions/checkout@v4 |
@@ -89,6 +92,128 @@ jobs: |
89 | 92 | |
90 | 93 | message: "chore(release): Update changelog and package version [skip ci]" |
91 | 94 |
|
| 95 | + - name: Get pre-release version |
| 96 | + id: get-pre-release-version |
| 97 | + run: | |
| 98 | + yarn tsx ./.github/scripts/before-beta-release.ts |
| 99 | + echo "pre_release_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT |
| 100 | +
|
| 101 | + build-bundles: |
| 102 | + name: Build bundles |
| 103 | + needs: [release_metadata, update_changelog] |
| 104 | + |
| 105 | + strategy: |
| 106 | + fail-fast: false |
| 107 | + matrix: |
| 108 | + include: |
| 109 | + - os: ubuntu-latest |
| 110 | + label: unix |
| 111 | + - os: windows-latest |
| 112 | + label: windows-x64 |
| 113 | + - os: windows-11-arm |
| 114 | + label: windows-arm64 |
| 115 | + |
| 116 | + runs-on: ${{ matrix.os }} |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Checkout repository |
| 120 | + uses: actions/checkout@v4 |
| 121 | + with: |
| 122 | + ref: ${{ needs.update_changelog.outputs.changelog_commitish }} |
| 123 | + |
| 124 | + - name: Use Node.js 22 |
| 125 | + uses: actions/setup-node@v4 |
| 126 | + with: |
| 127 | + node-version: 22 |
| 128 | + registry-url: https://registry.npmjs.org |
| 129 | + |
| 130 | + - name: Enable corepack |
| 131 | + run: | |
| 132 | + corepack enable |
| 133 | + corepack prepare yarn@stable --activate |
| 134 | +
|
| 135 | + - name: Activate cache for Node.js 22 |
| 136 | + uses: actions/setup-node@v4 |
| 137 | + with: |
| 138 | + cache: yarn |
| 139 | + |
| 140 | + - name: Install dependencies |
| 141 | + run: yarn |
| 142 | + |
| 143 | + - name: Install bun |
| 144 | + uses: oven-sh/setup-bun@v2 |
| 145 | + if: ${{ matrix.os != 'windows-11-arm' }} |
| 146 | + with: |
| 147 | + bun-version-file: .bun-version |
| 148 | + |
| 149 | + - name: Install bun (Windows ARM) |
| 150 | + if: ${{ matrix.os == 'windows-11-arm' }} |
| 151 | + run: | |
| 152 | + $bunVersion = (Get-Content .bun-version).Trim() |
| 153 | + irm bun.sh/install.ps1 -OutFile install.ps1 |
| 154 | +
|
| 155 | + # Bun doesn't have Windows ARM64 builds, so the setup-bun action fails. The install script however, |
| 156 | + # does "support" it. |
| 157 | +
|
| 158 | + .\install.ps1 -Version $bunVersion |
| 159 | +
|
| 160 | + Join-Path (Resolve-Path ~).Path ".bun\bin" >> $env:GITHUB_PATH |
| 161 | +
|
| 162 | + # https://github.com/oven-sh/bun/issues/11198 |
| 163 | + - name: Fix cross-platform building on Actions |
| 164 | + if: ${{ matrix.os != 'ubuntu-latest' }} |
| 165 | + run: | |
| 166 | + mkdir C:\test |
| 167 | + cd C:\test |
| 168 | + bun init -y |
| 169 | + bun build --compile --target=bun-windows-x64 --outfile test index.ts |
| 170 | + bun build --compile --target=bun-windows-x64-baseline --outfile test index.ts |
| 171 | +
|
| 172 | + # Check version consistency and increment pre-release version number for beta only. |
| 173 | + - name: Bump pre-release version |
| 174 | + run: yarn tsx ./.github/scripts/before-beta-release.ts |
| 175 | + |
| 176 | + - name: Build Bundles |
| 177 | + run: yarn insert-cli-metadata && yarn build-bundles |
| 178 | + |
| 179 | + - name: Upload bundles |
| 180 | + uses: actions/upload-artifact@v4 |
| 181 | + with: |
| 182 | + name: apify-cli-bundles-${{ matrix.label }} |
| 183 | + path: bundles/** |
| 184 | + |
| 185 | + create_github_release: |
| 186 | + name: Create GitHub release |
| 187 | + needs: [release_metadata, update_changelog, build-bundles] |
| 188 | + runs-on: ubuntu-latest |
| 189 | + |
| 190 | + env: |
| 191 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 192 | + |
| 193 | + steps: |
| 194 | + # This step also deals with unzipping the archive from GitHub, so we get a big folder with all the bundles! |
| 195 | + - name: Download bundles |
| 196 | + uses: actions/download-artifact@v4 |
| 197 | + with: |
| 198 | + pattern: apify-cli-bundles-* |
| 199 | + merge-multiple: true |
| 200 | + path: bundles |
| 201 | + |
| 202 | + - name: List bundles |
| 203 | + run: | |
| 204 | + ls -la bundles |
| 205 | +
|
| 206 | + - name: Create release |
| 207 | + uses: softprops/action-gh-release@v2 |
| 208 | + with: |
| 209 | + tag_name: v${{ needs.update_changelog.outputs.pre_release_version }} |
| 210 | + name: ${{ needs.update_changelog.outputs.pre_release_version }} |
| 211 | + target_commitish: ${{ needs.update_changelog.outputs.changelog_commitish }} |
| 212 | + body: ${{ needs.release_metadata.outputs.release_notes }} |
| 213 | + prerelease: true |
| 214 | + files: | |
| 215 | + bundles/* |
| 216 | +
|
92 | 217 | publish_to_npm: |
93 | 218 | name: Publish to NPM |
94 | 219 | needs: [update_changelog] |
@@ -129,12 +254,8 @@ jobs: |
129 | 254 | - name: Build module |
130 | 255 | run: yarn build |
131 | 256 |
|
132 | | - - name: Pack with yarn |
133 | | - run: yarn pack |
134 | | - |
135 | 257 | - name: Publish to NPM |
136 | 258 | run: | |
137 | | - # `yarn npm publish` does not currently support --provenance: https://github.com/yarnpkg/berry/issues/5430 |
138 | | - npm publish package.tgz --provenance --access public --tag beta |
| 259 | + yarn npm publish --provenance --access public --tag beta |
139 | 260 | env: |
140 | | - NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} |
| 261 | + YARN_NPM_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} |
0 commit comments