Repository navigation
143 lines (124 loc) · 4.44 KB
/
Copy pathrelease-javascript.yaml
File metadata and controls
143 lines (124 loc) · 4.44 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
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
136
137
138
139
140
141
142
143
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# All `uses:` action pins in this workflow must come from the Apache action allowlist:
# https://github.com/apache/infrastructure-actions/blob/main/actions.yml
name: Publish JavaScript
run-name: "JavaScript Release: ${{ github.ref_name }}"
on:
push:
tags: ['v*']
permissions:
contents: read
id-token: write
concurrency:
group: release-javascript-${{ github.ref }}
cancel-in-progress: false
jobs:
publish-npm:
runs-on: ubuntu-latest
if: github.repository == 'apache/fory' && !startsWith(github.ref_name, 'go/fory')
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm for trusted publishing
run: npm i -g npm@latest
- name: Verify Node/npm versions
shell: bash
run: |
set -euo pipefail
echo "Node: $(node --version)"
echo "npm: $(npm --version)"
REQUIRED="11.5.1"
CURRENT="$(npm --version)"
if [[ "$(printf '%s\n' "$REQUIRED" "$CURRENT" | sort -V | head -n1)" != "$REQUIRED" ]]; then
echo "npm version must be >= $REQUIRED for trusted publishing. current=$CURRENT"
exit 1
fi
- name: Bump javascript version
shell: bash
run: |
set -euo pipefail
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
python ci/release.py bump_version -l javascript -version "$VERSION"
- name: Install dependencies
shell: bash
working-directory: javascript
run: npm install
- name: Build packages
shell: bash
working-directory: javascript
run: npm run build
- name: Prepare npm for trusted publishing
shell: bash
run: |
set -euo pipefail
npm config set registry https://registry.npmjs.org/
npm config delete //registry.npmjs.org/:_authToken || true
npm config get registry
- name: Verify repository metadata for provenance
shell: bash
run: |
set -euo pipefail
node <<'EOF'
const fs = require("node:fs");
const expected = "https://github.com/apache/fory.git";
const files = [
"javascript/packages/core/package.json",
"javascript/packages/hps/package.json"
];
for (const file of files) {
const json = JSON.parse(fs.readFileSync(file, "utf8"));
const actual = json?.repository?.url ?? "";
if (actual !== expected) {
console.error(
`Repository URL mismatch in ${file}: expected "${expected}", got "${actual}"`
);
process.exit(1);
}
}
console.log("repository metadata verified for all publishable packages");
EOF
- name: Publish @apache-fory/hps
shell: bash
working-directory: javascript/packages/hps
run: |
set -euo pipefail
TAG="latest"
if echo "${{ github.ref_name }}" | grep -qE '[-]'; then
TAG="next"
fi
npm publish --access public --tag "$TAG" --provenance
env:
NODE_AUTH_TOKEN: ""
NPM_TOKEN: ""
- name: Publish @apache-fory/core
shell: bash
working-directory: javascript/packages/core
run: |
set -euo pipefail
TAG="latest"
if echo "${{ github.ref_name }}" | grep -qE '[-]'; then
TAG="next"
fi
npm publish --access public --tag "$TAG" --provenance
env:
NODE_AUTH_TOKEN: ""
NPM_TOKEN: ""