Skip to content

Commit e7c1e45

Browse files
authored
fix: rework build and publish [INS-1051] (#95)
* Trigger build on push to any branch * Publish binary without tag verification * Move release binary publishing to a gitHub actions workflow * Remove cleanup from build script * Fix token * Debugging failure * Fetch all history for all tags and branches on build * Hardcode release version for testing * Cleanup * More debugging * Fix packaging * More debugging * Move packaging back to build script; upload both arm64 and x64 Mac binaries * Hardcode electron version * More fixes * Fix publish for all binaries * Ignore existing binaries instead of overwriting them * Add missing token reference * Disable builds temporarily for existing release binaries * Ignore errors if a release binary exists * Skip conditional for windows build and disable all other builds * Fix typo * Fix publish binary command for windows * Only publish binaries when a tag exists * Replace hardcoded release version with current tag * Fail stage if a release build exists * Trigger builds only when a tag is added or when pushing to the develop branch * Create a draft release by triggering the version workflow on push * Fix default value for version input * Create the release without pushing a new tag * Fix default for version value * Bump default version * Fix tag and version * Cleanup * Bump tag and version * Switch to automated release on tag creation * Bump electron version to 37.x * Bump node-libcurl version to 3.0.0 * Disable creation of reelase version on push
1 parent 4ace750 commit e7c1e45

File tree

6 files changed

+131
-49
lines changed

6 files changed

+131
-49
lines changed

.electron-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
36.4.0
1+
37.2.6

.github/workflows/build-and-release.yaml

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ on:
1515
# all jobs here must have a matrix identical to the ones inside build-lint-test.yaml
1616

1717
jobs:
18+
release:
19+
permissions: write-all
20+
runs-on: ubuntu-22.04
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Create Tag and Release
29+
if: startsWith(github.ref, 'refs/tags/')
30+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1
31+
id: core_tag_and_release
32+
with:
33+
tag: v${{ env.TAG }}
34+
name: 'nodelibcurl v${{ env.TAG }} 📦'
35+
generateReleaseNotes: true
36+
prerelease: false
37+
draft: true
38+
1839
scan:
1940
permissions:
2041
packages: write
@@ -25,6 +46,7 @@ jobs:
2546
uses: actions/checkout@v4
2647
with:
2748
path: ${{ github.repository }}
49+
# fetch-depth: 0
2850

2951
# Perform SCA analysis for the code repository
3052
# Produces SBOM and CVE report
@@ -110,13 +132,34 @@ jobs:
110132
- name: 'Set GIT_TAG'
111133
if: startsWith(github.ref, 'refs/tags')
112134
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
113-
- name: 'Publish Binary'
135+
- name: 'Build Binary'
114136
run: |
115137
pip install packaging
116138
GIT_COMMIT=${{ github.sha }} \
117139
GIT_TAG=$GIT_TAG \
118140
RUNNER_OS=${{ matrix.os }} \
119141
./scripts/ci/build.sh
142+
- name: 'Publish Binary'
143+
if: runner.os != 'macOS' && startsWith(github.ref, 'refs/tags/')
144+
run: |
145+
gh release upload $(git describe --exact-match --tags) \
146+
"$(cat ./package.txt)"
147+
env:
148+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
- name: 'Publish x64 Mac Binary'
150+
if: runner.os == 'macOS' && startsWith(github.ref, 'refs/tags/')
151+
run: |
152+
gh release upload $(git describe --exact-match --tags) \
153+
"$(cat ./package_x64.txt)"
154+
env:
155+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
- name: 'Publish arm64 Mac Binary'
157+
if: runner.os == 'macOS' && startsWith(github.ref, 'refs/tags/')
158+
run: |
159+
gh release upload $(git describe --exact-match --tags) \
160+
"$(cat ./package_arm64.txt)"
161+
env:
162+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120163
- name: Upload artifacts
121164
if: always()
122165
uses: actions/upload-artifact@v4
@@ -178,12 +221,33 @@ jobs:
178221
- name: 'Set GIT_TAG'
179222
if: startsWith(github.ref, 'refs/tags')
180223
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
181-
- name: 'Publish Binary'
224+
- name: 'Build Binary'
182225
run: |
183226
pip install packaging
184227
GIT_COMMIT=${{ github.sha }} \
185228
GIT_TAG=$GIT_TAG \
186229
./scripts/ci/build.sh
230+
- name: 'Publish Binary'
231+
if: runner.os != 'macOS' && startsWith(github.ref, 'refs/tags/')
232+
run: |
233+
gh release upload $(git describe --exact-match --tags) \
234+
"$(cat ./package.txt)"
235+
env:
236+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
237+
- name: 'Publish x64 Mac Binary'
238+
if: runner.os == 'macOS' && startsWith(github.ref, 'refs/tags/')
239+
run: |
240+
gh release upload $(git describe --exact-match --tags) \
241+
"$(cat ./package_x64.txt)"
242+
env:
243+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244+
- name: 'Publish arm64 Mac Binary'
245+
if: runner.os == 'macOS' && startsWith(github.ref, 'refs/tags/')
246+
run: |
247+
gh release upload $(git describe --exact-match --tags) \
248+
"$(cat ./package_arm64.txt)"
249+
env:
250+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187251
- name: Upload artifacts
188252
if: always()
189253
uses: actions/upload-artifact@v4
@@ -229,12 +293,18 @@ jobs:
229293
if ($LASTEXITCODE -eq 0) {
230294
$host.SetShouldExit(0)
231295
}
232-
- name: Publish binary
296+
- name: Build binary
233297
if: startsWith(github.ref, 'refs/tags/')
234298
run: |
235299
pip install packaging
236300
npm run pregyp package testpackage --verbose
237-
node scripts\module-packaging.js --publish $(npm run -s pregyp reveal staged_tarball --silent)
301+
# node scripts\module-packaging.js --publish $(npm run -s pregyp reveal staged_tarball --silent)
302+
- name: Publish Binary
303+
if: startsWith(github.ref, 'refs/tags/')
304+
run: |
305+
gh release upload $(git describe --exact-match --tags) $(npm run -s pregyp reveal staged_tarball --silent)
306+
env:
307+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
238308

239309
build-and-release-electron-windows:
240310
needs: setup
@@ -277,9 +347,14 @@ jobs:
277347
if ($LASTEXITCODE -eq 0) {
278348
$host.SetShouldExit(0)
279349
}
280-
- name: Publish binary
350+
- name: Build binary
281351
if: startsWith(github.ref, 'refs/tags/')
282352
run: |
283353
pip install packaging
284354
npm run pregyp package testpackage --verbose
285-
node scripts\module-packaging.js --publish $(npm run -s pregyp reveal staged_tarball --silent)
355+
- name: Publish Binary
356+
if: startsWith(github.ref, 'refs/tags/')
357+
run: |
358+
gh release upload $(git describe --exact-match --tags) $(npm run -s pregyp reveal staged_tarball --silent)
359+
env:
360+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/new-version.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@ jobs:
2020
uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
23-
token: ${{ secrets.PAT_INSOMNIA_INFRA }}
23+
token: ${{ secrets.GITHUB_TOKEN }}
2424

2525
- name: Configure Git user
2626
uses: Homebrew/actions/git-user-config@266845213695c3047d210b2e8fbc42ecdaf45802 # master
2727
with:
2828
username: ${{ (github.event_name == 'workflow_dispatch' && github.actor) || 'insomnia-infra' }}
2929

30-
- name: Setup Node
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version-file: '.node-version'
30+
# - name: Setup Node
31+
# uses: actions/setup-node@v4
32+
# with:
33+
# node-version-file: '.node-version'
3434

35-
- name: Install
36-
run: npm ci --ignore-scripts
35+
# - name: Install
36+
# run: npm ci --ignore-scripts
3737

38-
- name: Create new package version
39-
run: npm version "${{ env.TAG }}"
38+
# - name: Create new package version
39+
# run: npm version "${{ env.TAG }}"
4040

4141
- name: DEBUG see tags
4242
run: |
4343
git tag --list
4444
git remote -v
4545
46-
- name: Merge version commit into develop
47-
run: |
48-
git push origin v${{ env.TAG }}
49-
git push origin develop
46+
# - name: Merge version commit into develop
47+
# run: |
48+
# git push origin v${{ env.TAG }}
49+
# git push origin develop
5050

5151
- name: Create Tag and Release
5252
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1
@@ -56,4 +56,4 @@ jobs:
5656
name: 'nodelibcurl v${{ env.TAG }} 📦'
5757
generateReleaseNotes: true
5858
prerelease: false
59-
draft: false
59+
draft: true

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@getinsomnia/node-libcurl",
3-
"version": "2.36.12",
3+
"version": "3.0.0",
44
"description": "The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl",
55
"keywords": [
66
"node-curl",

scripts/ci/build.sh

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -373,45 +373,52 @@ if [ "$RUN_TESTS" == "true" ]; then
373373
fi
374374
fi
375375

376+
echo "=== node version: $(node -v)"
377+
376378
# If we are here, it means the addon worked
377379
# Check if we need to publish the binaries
378380
if [[ $PUBLISH_BINARY == true && $LIBCURL_RELEASE == $LATEST_LIBCURL_RELEASE ]]; then
379381
echo "=== Publish binary is true - Testing and publishing package with pregyp"
380382
if [[ "$MACOS_UNIVERSAL_BUILD" == "true" ]]; then
381383
# Need to publish two binaries when doing a universal build.
382384
# --
383-
# Publish x64 package
385+
# Build x64 package
384386
npm_config_target_arch=x64 npm run pregyp package testpackage --verbose
385-
npm_config_target_arch=x64 node scripts/module-packaging.js --publish \
386-
"$(npm_config_target_arch=x64 npm run --silent pregyp reveal staged_tarball --silent)"
387-
# Publish arm64 package.
387+
npm_config_target_arch=x64 npm run --silent pregyp reveal staged_tarball --silent>package_x64.txt
388+
# npm_config_target_arch=x64 node scripts/module-packaging.js --publish \
389+
# "$(npm_config_target_arch=x64 npm run --silent pregyp reveal staged_tarball --silent)"
390+
# Build arm64 package.
388391
npm_config_target_arch=arm64 npm run pregyp package --verbose # Can't testpackage for arm64 yet.
389-
npm_config_target_arch=arm64 node scripts/module-packaging.js --publish \
390-
"$(npm_config_target_arch=arm64 npm run --silent pregyp reveal staged_tarball --silent)"
392+
npm_config_target_arch=arm64 npm run --silent pregyp reveal staged_tarball --silent>package_arm64.txt
393+
# npm_config_target_arch=arm64 node scripts/module-packaging.js --publish \
394+
# "$(npm_config_target_arch=arm64 npm run --silent pregyp reveal staged_tarball --silent)"
391395
else
392396
npm run pregyp package testpackage --verbose
393-
node scripts/module-packaging.js --publish "$(npm run --silent pregyp reveal staged_tarball --silent)"
397+
npm run --silent pregyp reveal staged_tarball --silent>package.txt
398+
# node scripts/module-packaging.js --publish "$(npm run --silent pregyp reveal staged_tarball --silent)"
394399
fi
395400
fi
396-
echo "=== node version: $(node -v)"
397-
# In case we published the binaries, verify if we can download them, and that they work
398-
# Otherwise, unpublish them
399-
INSTALL_RESULT=0
400-
if [[ $PUBLISH_BINARY == true ]]; then
401-
echo "=== Publish binary is true - Testing if it was published correctly"
402401

403-
INSTALL_RESULT=$(npm_config_fallback_to_build=false npm ci > /dev/null)$? || true
404-
fi
405-
if [[ $INSTALL_RESULT != 0 ]]; then
406-
echo "=== Failed to install package from npm after being published"
407-
node scripts/module-packaging.js --unpublish "$(npm run --silent pregyp reveal hosted_tarball --silent)"
408-
false
409-
fi
402+
## Move this to action or a different script later
403+
# echo "=== node version: $(node -v)"
404+
# # In case we published the binaries, verify if we can download them, and that they work
405+
# # Otherwise, unpublish them
406+
# INSTALL_RESULT=0
407+
# if [[ $PUBLISH_BINARY == true ]]; then
408+
# echo "=== Publish binary is true - Testing if it was published correctly"
410409

411-
# Clean everything
412-
if [[ $RUN_PREGYP_CLEAN == true ]]; then
413-
echo "=== cleanup"
414-
npm run pregyp clean
415-
fi
410+
# INSTALL_RESULT=$(npm_config_fallback_to_build=false npm ci > /dev/null)$? || true
411+
# fi
412+
# if [[ $INSTALL_RESULT != 0 ]]; then
413+
# echo "=== Failed to install package from npm after being published"
414+
# node scripts/module-packaging.js --unpublish "$(npm run --silent pregyp reveal hosted_tarball --silent)"
415+
# false
416+
# fi
417+
418+
# # Clean everything
419+
# if [[ $RUN_PREGYP_CLEAN == true ]]; then
420+
# echo "=== cleanup"
421+
# npm run pregyp clean
422+
# fi
416423

417424
set +uv

0 commit comments

Comments
 (0)