Skip to content

Commit 73c020e

Browse files
committed
Improve python package publish and add nodejs package publish.
1 parent cd0348f commit 73c020e

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release NodeJS Package
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
paths:
7+
- 'source/ports/node_port/package.json'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
release:
15+
name: Release NodeJS Port
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Release the port
23+
working-directory: source/ports/node_port
24+
env:
25+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26+
run: ./upload.sh

source/ports/node_port/upload.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,24 @@
1919
# limitations under the License.
2020
#
2121

22-
# TODO: Update version in package.json
23-
# TODO: Automate for CD/CI
22+
set -euxo pipefail
23+
24+
NPM_VERSION=$(npm view metacall version)
25+
PORT_VERSION=$(node -p "require('./package.json').version")
26+
27+
if [[ "$NPM_VERSION" == "$PORT_VERSION" ]]; then
28+
echo "Current package version is the same as NPM version, skipping upload."
29+
exit 0
30+
fi
31+
32+
if [[ -z "${NPM_TOKEN:-}" ]]; then
33+
echo "NPM_TOKEN environment variable is not set or empty, skipping upload"
34+
exit 1
35+
fi
36+
37+
# Register the token
38+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
2439

2540
# Publish
26-
npm login && npm publish
41+
npm login
42+
npm publish

source/ports/py_port/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.1
1+
0.5.2

source/ports/py_port/upload.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ if [[ "$PYPI_VERSION" == "$PORT_VERSION" ]]; then
3030
fi
3131

3232
# Install dependencies and upload MetaCall package
33-
python3 -m pip install --user --upgrade twine setuptools wheel # build
34-
# python3 -m build
33+
python3 -m pip install --user --upgrade twine setuptools wheel
3534
python3 setup.py sdist bdist_wheel
3635
python3 -m twine check dist/*
3736
python3 -m twine upload dist/*

0 commit comments

Comments
 (0)