forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (88 loc) Β· 3.87 KB
/
build-node-fibers.yml
File metadata and controls
98 lines (88 loc) Β· 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Build Custom Fibers
on:
workflow_dispatch:
workflow_run:
workflows: ["Build Node (Standard)"]
types:
- completed
branches:
- v22.21.1
jobs:
build-fibers:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
strategy:
matrix:
include:
- platform: linux
arch: x64
runs_on: ubuntu-22.04
- platform: linux
arch: arm64
runs_on: ubuntu-22.04-arm
runs-on: ${{ matrix.runs_on }}
env:
NODE_VERSION: v22.21.1
REPO: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Debug Matrix Values
run: |
echo "Matrix platform: ${{ matrix.platform }}"
echo "Matrix arch: ${{ matrix.arch }}"
- name: Download Node archive
run: |
gh release download node-${{ env.NODE_VERSION }}-release \
--repo asana/node \
--pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz"
mv node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz node.tar.xz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Execute the Dockerfile
run: |
pwd
docker build -t node22_fibers_build -f Dockerfile.Fibers .
- name: Extract resources
run: |
docker create --name temp_node_fibers_extract node22_fibers_build
docker cp temp_node_fibers_extract:/usr/src/node/node-fibers $GITHUB_WORKSPACE/node-fibers
docker rm temp_node_fibers_extract
- name: Find and archive fibers.node
run: |
# Find the directory under bin/ that contains fibers.node
FIBERS_PATH=$(find ./node-fibers/bin -type f -name fibers.node | head -n1)
FIBERS_DIR=$(dirname "$FIBERS_PATH")
ARCHIVE_NAME=$(basename "$FIBERS_DIR").tar.gz
echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $GITHUB_ENV
tar -czf "$ARCHIVE_NAME" -C "$(dirname "$FIBERS_DIR")" "$(basename "$FIBERS_DIR")"
- name: Upload archive to release
# Attach the built node-fibers archive to the same node-${NODE_VERSION}-release
# release that hosts the corresponding Node binaries.
#
# Normally this workflow runs after Build Node via workflow_run, so the
# release already exists by the time we get here. But workflow_dispatch can
# fire it independently (release may not yet exist), and the matrix still
# runs both arms (linux-x64, linux-arm64) in parallel β so both arms can
# race to create the release. The view-or-create guard with the trailing
# `|| gh release view` tolerates "already exists" from a losing racer and
# propagates any other create failure through the final view.
#
# `--clobber` makes re-uploads idempotent on asset name collisions by
# deleting the existing asset before uploading. If the new upload fails
# after the delete, just re-run the job to rebuild.
#
# `gh release edit --title` after upload keeps the release title
# deterministically derived from NODE_VERSION, overriding any manual rename
# in the GitHub UI.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="node-${NODE_VERSION}-release"
RELEASE_NAME="node-${NODE_VERSION}-LATEST"
if ! gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
gh release create "$TAG" --title "$RELEASE_NAME" --notes "" --repo "$REPO" \
|| gh release view "$TAG" --repo "$REPO" >/dev/null
fi
gh release upload "$TAG" "$ARCHIVE_NAME" --clobber --repo "$REPO"
gh release edit "$TAG" --title "$RELEASE_NAME" --repo "$REPO"