Skip to content

Commit 51ef00a

Browse files
authored
feat: upgrade command, install shell script (#810)
1 parent b9aa0ca commit 51ef00a

27 files changed

+1577
-561
lines changed

.bun-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.2.14

.github/workflows/check.yaml

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest, windows-latest]
22-
node-version: [18, 20, 22]
22+
node-version: [18, 20, 22, 24]
2323

2424
steps:
2525
- name: Mask secrets
@@ -71,17 +71,17 @@ jobs:
7171
7272
- uses: actions/checkout@v4
7373

74-
- name: Use Node.js 20
74+
- name: Use Node.js 22
7575
uses: actions/setup-node@v4
7676
with:
77-
node-version: 20
77+
node-version: 22
7878

7979
- name: Enable corepack
8080
run: |
8181
corepack enable
8282
corepack prepare yarn@stable --activate
8383
84-
- name: Activate cache for Node.js 20
84+
- name: Activate cache for Node.js 22
8585
uses: actions/setup-node@v4
8686
with:
8787
cache: yarn
@@ -108,17 +108,17 @@ jobs:
108108
- name: Checkout Source code
109109
uses: actions/checkout@v4
110110

111-
- name: Use Node.js 20
111+
- name: Use Node.js 22
112112
uses: actions/setup-node@v4
113113
with:
114-
node-version: 20
114+
node-version: 22
115115

116116
- name: Enable corepack
117117
run: |
118118
corepack enable
119119
corepack prepare yarn@stable --activate
120120
121-
- name: Activate cache for Node.js 20
121+
- name: Activate cache for Node.js 22
122122
uses: actions/setup-node@v4
123123
with:
124124
cache: yarn
@@ -139,17 +139,17 @@ jobs:
139139
steps:
140140
- uses: actions/checkout@v4
141141

142-
- name: Use Node.js 20
142+
- name: Use Node.js 22
143143
uses: actions/setup-node@v4
144144
with:
145-
node-version: 20
145+
node-version: 22
146146

147147
- name: Enable corepack
148148
run: |
149149
corepack enable
150150
corepack prepare yarn@stable --activate
151151
152-
- name: Activate cache for Node.js 20
152+
- name: Activate cache for Node.js 22
153153
uses: actions/setup-node@v4
154154
with:
155155
cache: yarn
@@ -164,38 +164,77 @@ jobs:
164164
run: yarn format
165165

166166
build_bundles:
167-
name: Build Test Bundles
168-
runs-on: ubuntu-latest
167+
name: Build Test Bundles (${{ matrix.label }})
169168
needs: [build_and_test]
170169

170+
strategy:
171+
fail-fast: false
172+
matrix:
173+
include:
174+
- os: ubuntu-latest
175+
label: unix
176+
- os: windows-latest
177+
label: windows-x64
178+
- os: windows-11-arm
179+
label: windows-arm64
180+
181+
runs-on: ${{ matrix.os }}
182+
171183
steps:
172184
- uses: actions/checkout@v4
173185

174-
- name: Use Node.js 20
186+
- name: Use Node.js 22
175187
uses: actions/setup-node@v4
188+
with:
189+
node-version: 22
176190

177191
- name: Enable corepack
178192
run: |
179193
corepack enable
180194
corepack prepare yarn@stable --activate
181195
182-
- name: Activate cache for Node.js 20
196+
- name: Activate cache for Node.js 22
183197
uses: actions/setup-node@v4
184198
with:
185199
cache: yarn
186200

187201
- name: Install Dependencies
188202
run: yarn
189203

190-
- uses: oven-sh/setup-bun@v2
204+
- name: Install bun
205+
uses: oven-sh/setup-bun@v2
206+
if: ${{ matrix.os != 'windows-11-arm' }}
191207
with:
192-
bun-version: latest
208+
bun-version-file: .bun-version
209+
210+
- name: Install bun (Windows ARM)
211+
if: ${{ matrix.os == 'windows-11-arm' }}
212+
run: |
213+
$bunVersion = (Get-Content .bun-version).Trim()
214+
irm bun.sh/install.ps1 -OutFile install.ps1
215+
216+
# Bun doesn't have Windows ARM64 builds, so the setup-bun action fails. The install script however,
217+
# does "support" it.
218+
219+
.\install.ps1 -Version $bunVersion
220+
221+
Join-Path (Resolve-Path ~).Path ".bun\bin" >> $env:GITHUB_PATH
222+
223+
# https://github.com/oven-sh/bun/issues/11198
224+
- name: Fix cross-platform building on Actions
225+
if: ${{ matrix.os != 'ubuntu-latest' }}
226+
run: |
227+
mkdir C:\test
228+
cd C:\test
229+
bun init -y
230+
bun build --compile --target=bun-windows-x64 --outfile test index.ts
231+
bun build --compile --target=bun-windows-x64-baseline --outfile test index.ts
193232
194233
- name: Build Bundles
195-
run: yarn build-bundles
234+
run: yarn insert-cli-metadata && yarn build-bundles
196235

197236
- name: Upload Bundles
198237
uses: actions/upload-artifact@v4
199238
with:
200-
name: apify-cli-bundles
201-
path: bundles/apify**
239+
name: apify-cli-bundles-${{ matrix.label }}
240+
path: bundles/**

.github/workflows/pre_release.yaml

Lines changed: 127 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
outputs:
2121
version_number: ${{ steps.release_metadata.outputs.version_number }}
2222
changelog: ${{ steps.release_metadata.outputs.changelog }}
23+
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
2324
steps:
2425
- uses: apify/workflows/git-cliff-release@main
2526
name: Prepare release metadata
@@ -45,6 +46,8 @@ jobs:
4546
runs-on: ubuntu-latest
4647
outputs:
4748
changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }}
49+
pre_release_version: ${{ steps.get-pre-release-version.outputs.pre_release_version }}
50+
4851
steps:
4952
- name: Checkout repository
5053
uses: actions/checkout@v4
@@ -89,6 +92,128 @@ jobs:
8992
author_email: [email protected]
9093
message: "chore(release): Update changelog and package version [skip ci]"
9194

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+
92217
publish_to_npm:
93218
name: Publish to NPM
94219
needs: [update_changelog]
@@ -129,12 +254,8 @@ jobs:
129254
- name: Build module
130255
run: yarn build
131256

132-
- name: Pack with yarn
133-
run: yarn pack
134-
135257
- name: Publish to NPM
136258
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
139260
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

Comments
 (0)