@@ -11,68 +11,19 @@ permissions:
1111jobs :
1212 publish :
1313 runs-on : ubuntu-latest
14- defaults :
15- run :
16- working-directory : TMLSPEC-cli
1714
1815 steps :
1916 - name : Checkout code
2017 uses : actions/checkout@v4
2118
22- - name : Setup Node.js
23- uses : actions/setup-node@v4
24- with :
25- node-version : ' 20.x'
26- cache : npm
27- cache-dependency-path : TMLSPEC-cli/package-lock.json
28-
29- - name : Validate publish secrets
30- shell : bash
31- run : |
32- if [ -z "${{ secrets.NPM_REGISTRY_URL }}" ]; then
33- echo "Missing required secret: NPM_REGISTRY_URL" >&2
34- exit 1
35- fi
36-
37- if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
38- echo "Missing required secret: NPM_TOKEN" >&2
39- exit 1
40- fi
41-
42- - name : Install dependencies
43- run : npm ci
44-
45- - name : Build
46- run : npm run build
47-
48- - name : Set package version from tag
49- shell : bash
50- run : |
51- RAW_TAG="${GITHUB_REF_NAME}"
52- VERSION="${RAW_TAG#v}"
53-
54- if [ -z "$VERSION" ] || [ "$VERSION" = "$RAW_TAG" ]; then
55- echo "Unable to derive package version from tag: $RAW_TAG" >&2
56- exit 1
57- fi
58-
59- npm pkg set version="$VERSION"
60-
61- - name : Configure self-hosted npm registry
62- shell : bash
63- run : |
64- REGISTRY_URL="${{ secrets.NPM_REGISTRY_URL }}"
65- REGISTRY_HOST="${REGISTRY_URL#https://}"
66- REGISTRY_HOST="${REGISTRY_HOST#http://}"
67- REGISTRY_HOST="${REGISTRY_HOST%/}"
68-
69- cat <<EOF > ~/.npmrc
70- registry=${REGISTRY_URL}
71- //${REGISTRY_HOST}/:_authToken=${{ secrets.NPM_TOKEN }}
72- always-auth=true
73- EOF
74-
7519 - name : Publish package
76- run : npm publish
77- env :
78- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
20+ uses : Time-Machine-Lab/TML-Github_Actions/actions/publish-node-package@main
21+ with :
22+ cache_dependency_path : TMLSPEC-cli/package-lock.json
23+ node_version : ' 20.x'
24+ working_directory : TMLSPEC-cli
25+ build_command : npm run build
26+ publish_command : npm publish
27+ tag_prefix : v
28+ registry_url : ${{ secrets.NPM_REGISTRY_URL }}
29+ npm_token : ${{ secrets.NPM_TOKEN }}
0 commit comments