Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build package #5

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "TBD"
bin/generate-package.sh
bin/publish-package.sh
11 changes: 11 additions & 0 deletions bin/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e
[ -n "$DEBUG" ] && set -x

unpublished_exists() {
j-zimnowoda marked this conversation as resolved.
Show resolved Hide resolved
local version=$1
if [ -n "$(npm info "@linode/apl-k8s-operator@$version")" ]; then
return 0
fi
return 1
}
25 changes: 25 additions & 0 deletions bin/generate-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -e

org=linode
repo='ssh://[email protected]/linode/apl-k8s-operator-node.git'
j-zimnowoda marked this conversation as resolved.
Show resolved Hide resolved



type="node"
version=$(jq -r '.version' package.json)
registry="https://npm.pkg.github.com/"
target_package_json="package.json"
target_tsconfig_json="tsconfig.json"
target_npm_name="@$org/apl-k8s-operator"

build_npm_package() {
echo "Building $target_npm_name npm package"
npm install && npm run build
cd $DIR
}

build_npm_package

echo "The package code has been generated at root directory"
15 changes: 15 additions & 0 deletions bin/publish-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
. bin/common.sh

version=$(jq -r '.version' package.json)

release() {
if ! unpublished_exists $version; then
local pkg="@linode/apl-k8s-operator@$version"
echo "Publishing newer package: $pkg"
npm publish --access public
cd -
fi
}

release
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@linode/apl-k8s-operator",
"version": "1.3.9",
"version": "0.1.0",
"description": "Build Kubernetes operators in NodeJS (and TypeScript)",
"repository": {
"type": "git",
Expand Down Expand Up @@ -40,7 +40,9 @@
"clean": "rm -Rf node_modules/ dist/",
"build": "tsc",
"watch": "tsc --watch",
"prepare": "rm -Rf dist/ && npm run build"
"prepare": "rm -Rf dist/ && npm run build",
"build:package": "bin/generate-package.sh",
"publish:package": "bin/publish-package.sh"
},
"keywords": [
"kubernetes",
Expand Down
Loading