-
Notifications
You must be signed in to change notification settings - Fork 592
135 lines (115 loc) · 4.19 KB
/
build-npm-packages.yml
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: "Build NPM Packages"
on:
workflow_call:
inputs:
ice_version:
required: false
type: string
registry_url:
required: false
type: string
secrets:
NPM_AUTH_TOKEN:
required: false
workflow_dispatch:
inputs:
ice_version:
description: "The Ice version to build"
required: false
registry_url:
description: "The URL of the NPM registry to publish to"
required: false
type: string
jobs:
build-slice-compilers:
strategy:
matrix:
include:
- os: macos-latest
target: macos-arm64
artifact-path: cpp/bin/slice2js
- os: windows-latest
target: windows-x64
artifact-path: cpp/bin/x64/Release/slice2js.*
- os: ubuntu-24.04
target: linux-x64
artifact-path: cpp/bin/slice2js
- os: ubuntu-24.04-arm
target: linux-arm64
artifact-path: cpp/bin/slice2js
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Dependencies
uses: ./.github/actions/setup-dependencies
- name: Build Compiler
uses: ./.github/actions/build-slice-compiler
with:
compiler-name: slice2js
- name: Upload Compiler Artifact
uses: actions/upload-artifact@v4
with:
name: slice2js-${{ matrix.target }}
path: ${{ matrix.artifact-path }}
pack-npm:
runs-on: ubuntu-24.04
needs: build-slice-compilers
env:
SLICE2JS_STAGING_PATH: ${{ github.workspace }}/staging
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ice
- name: Download All Compiler Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Copy slice2js binaries to staging path
run: |
# Create the staging path.
mkdir -p "$SLICE2JS_STAGING_PATH/macos-arm64" \
"$SLICE2JS_STAGING_PATH/linux-x64" \
"$SLICE2JS_STAGING_PATH/linux-arm64" \
"$SLICE2JS_STAGING_PATH/windows-x64"
# Copy the slice2js binaries to the staging path.
cp -v artifacts/slice2js-macos-arm64/slice2js "$SLICE2JS_STAGING_PATH/macos-arm64/"
chmod +x $SLICE2JS_STAGING_PATH/macos-arm64/slice2js
cp -v artifacts/slice2js-linux-x64/slice2js "$SLICE2JS_STAGING_PATH/linux-x64/"
chmod +x $SLICE2JS_STAGING_PATH/linux-x64/slice2js
cp -v artifacts/slice2js-linux-arm64/slice2js "$SLICE2JS_STAGING_PATH/linux-arm64/"
chmod +x $SLICE2JS_STAGING_PATH/linux-arm64/slice2js
cp -v artifacts/slice2js-windows-x64/slice2js.exe "$SLICE2JS_STAGING_PATH/windows-x64/"
# Copy the slice2js binary to the cpp/bin directory to avoid rebuilding it.
mkdir -p ice/cpp/bin
cp -v artifacts/slice2js-linux-x64/slice2js $GITHUB_WORKSPACE/ice/cpp/bin/slice2js
chmod +x $GITHUB_WORKSPACE/ice/cpp/bin/slice2js
- name: Build JS
run: make
working-directory: ice/js
- name: Update Version
working-directory: ice/js
run: npm version ${{ inputs.ice_version }}
if: inputs.ice_version != ''
- name: Pack npm
run: npm pack
working-directory: ice/js
- name: Upload NPM Packages
uses: actions/upload-artifact@v4
with:
name: js-npm-packages
path: ice/js/*.tgz
- name: Publish NPM Packages
working-directory: ice/js
run: |
# Compute the prefix for .npmrc by removing http: or https: from the registry URL
export REPOSITORY_PREFIX=$(echo "${{ inputs.registry_url }}" | sed -E 's|^https?:||')
# Write authentication token reference to .npmrc (keeps it as an env variable)
echo "${REPOSITORY_PREFIX}:_auth=\${NPM_AUTH_TOKEN}" > ~/.npmrc
echo "always-auth=true" >> ~/.npmrc
# Publish package
npm publish *.tgz --registry ${{ inputs.registry_url }}
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
if: inputs.registry_url != ''