Skip to content

Commit 33df838

Browse files
authored
Add GitHub actions workflow for publishing kpt-functions to NPM registry. (#57)
* Add GitHub actions workflow for publishing kpt-functions to registry.
1 parent a360dfe commit 33df838

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: CI
22

33
on:
4-
# Trigger the workflow on push or pull request,
5-
# but only for the master branch
64
push:
75
branches:
86
- master
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: release-kpt-functions
2+
3+
on:
4+
push:
5+
tags:
6+
- release-kpt-functions-*
7+
8+
jobs:
9+
node-ci:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Use Node.js 12.x
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: 12.x
17+
registry-url: 'https://npm.pkg.github.com'
18+
- name: Install, test
19+
run: |
20+
cd ts/kpt-functions
21+
npm ci
22+
npm test
23+
- name: Publish
24+
run: |
25+
cd ts/kpt-functions
26+
../../scripts/publish-npm.sh $GITHUB_REF
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/publish-npm.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
TAG_VERSION=${1#*-v};
19+
echo "tag version: $TAG_VERSION"
20+
21+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
22+
echo "package version: $PACKAGE_VERSION"
23+
24+
if [[ "$PACKAGE_VERSION" != "$TAG_VERSION" ]]; then
25+
echo "package version does not match the tag"
26+
exit 1
27+
fi
28+
29+
30+
if [[ "$PACKAGE_VERSION" == *"rc"* ]]; then
31+
npm publish --tag rc
32+
else
33+
npm publish
34+
fi

0 commit comments

Comments
 (0)