Skip to content

Commit 270ab25

Browse files
committed
fix
1 parent d053ea0 commit 270ab25

File tree

5 files changed

+174
-126
lines changed

5 files changed

+174
-126
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
name: Build, Test, and Deliver Client
2-
3-
env:
4-
do_sonarscan: >-
5-
${{ (github.event_name == 'push' ||
6-
github.event.pull_request.head.repo.full_name == github.repository) &&
7-
github.actor != 'dependabot[bot]' }}
1+
name: "Build and Test Client"
82

93
on:
104
pull_request:
@@ -231,94 +225,6 @@ jobs:
231225
js-ref: ${{ github.ref }} latest lts
232226
platform-ref: main lts
233227

234-
deliver-ghp:
235-
needs:
236-
- lib
237-
- cli
238-
- web-app
239-
- scripts
240-
- platform-xtest
241-
runs-on: ubuntu-latest
242-
timeout-minutes: 5
243-
# To publish from a release or feature branch, remove the ref == condition below
244-
if: >-
245-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
246-
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')) ||
247-
(github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
248-
outputs:
249-
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
250-
DIST_TAG: ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
251-
TARGET_VERSION: ${{ steps.check-version.outputs.TARGET_VERSION }}
252-
steps:
253-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
254-
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e #v4.3.0
255-
with:
256-
node-version: '22'
257-
registry-url: https://npm.pkg.github.com
258-
- name: Check version number is same between tag, library, and/or release
259-
id: check-version
260-
run: |-
261-
if [[ ${{ github.ref }} = refs/heads/release/* ]]; then
262-
scripts/check-version-is.sh "${GITHUB_REF##*release/}"
263-
elif [[ ${{ github.ref }} = refs/tags/sdk/v* ]]; then
264-
scripts/check-version-is.sh "${GITHUB_REF_NAME#sdk/v}"
265-
else
266-
scripts/check-version-is.sh
267-
fi
268-
- name: Check version number is same between tag, library, and/or release
269-
id: guess-build-metadata
270-
run: |-
271-
echo "FULL_VERSION=$(.github/workflows/gh-semver.sh)" >> $GITHUB_OUTPUT
272-
echo "DIST_TAG=$(.github/workflows/guess-dist-tag.sh)" >> $GITHUB_OUTPUT
273-
- run: make doc
274-
- run: >-
275-
echo "::notice file=lib/package.json::Will be published to
276-
[GitHub Packages](https://github.com/opentdf/web-sdk/pkgs/npm/client)
277-
as ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
278-
with version=[${{ steps.guess-build-metadata.outputs.FULL_VERSION }}]"
279-
- run: >-
280-
.github/workflows/publish-to.sh
281-
"${{ steps.guess-build-metadata.outputs.FULL_VERSION }}"
282-
"${{ steps.guess-build-metadata.outputs.DIST_TAG }}"
283-
env:
284-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
285-
- run: echo "- [Client Library](https://github.com/opentdf/web-sdk/pkgs/npm/client)">>$GITHUB_STEP_SUMMARY
286-
- run: echo "- [Command Line Tool](https://github.com/opentdf/web-sdk/pkgs/npm/cli)">>$GITHUB_STEP_SUMMARY
287-
- name: Publish documentation to gh-pages
288-
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 #v4.7.3
289-
with:
290-
branch: gh-pages
291-
folder: lib/dist/docs
292-
293-
deliver-npmjs:
294-
runs-on: ubuntu-latest
295-
timeout-minutes: 5
296-
environment: npmjs
297-
needs: deliver-ghp
298-
if: >-
299-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
300-
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')) ||
301-
(github.event_name == 'release' && startsWith(github.ref, 'refs/tags/sdk/v'))
302-
steps:
303-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
304-
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e #v4.3.0
305-
with:
306-
node-version: '22'
307-
registry-url: 'https://registry.npmjs.org'
308-
- run: make all
309-
- run: >-
310-
.github/workflows/publish-to.sh
311-
"${{ needs.deliver-ghp.outputs.FULL_VERSION }}"
312-
"${{ needs.deliver-ghp.outputs.DIST_TAG }}"
313-
env:
314-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
315-
- run: >-
316-
echo "- [Client Library](https://www.npmjs.com/package/@opentdf/sdk/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
317-
- run: >-
318-
echo "- [Command Line Tool](https://www.npmjs.com/package/@opentdf/ctl/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
319-
- run: >-
320-
echo "- [unpkg](https://unpkg.com/browse/@opentdf/sdk@${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
321-
322228
ci:
323229
needs:
324230
- lib

.github/workflows/deliver.yaml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: "Deliver Client to npm registry"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/[0-9]+.[0-9]+.[0-9]+
8+
release:
9+
types:
10+
- created
11+
12+
# Default empty permissions for all jobs
13+
permissions: {}
14+
15+
jobs:
16+
deliver-ghp:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
20+
DIST_TAG: ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
21+
TARGET_VERSION: ${{ steps.check-version.outputs.TARGET_VERSION }}
22+
23+
steps:
24+
- name: "Checkout repo"
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
27+
- name: "Setup node"
28+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
29+
with:
30+
node-version: "22"
31+
registry-url: https://npm.pkg.github.com
32+
33+
- name: "Check version number is same between tag, library, and/or release"
34+
id: check-version
35+
env:
36+
REF: ${{ github.ref }}
37+
run: |
38+
if [[ "$REF" = refs/heads/release/* ]]; then
39+
scripts/check-version-is.sh "${GITHUB_REF##*release/}"
40+
elif [[ "$REF" = refs/tags/sdk/v* ]]; then
41+
scripts/check-version-is.sh "${GITHUB_REF_NAME#sdk/v}"
42+
else
43+
scripts/check-version-is.sh
44+
fi
45+
46+
- name: "Output build metadata"
47+
id: guess-build-metadata
48+
run: |
49+
FULL_VERSION=$(.github/workflows/gh-semver.sh)
50+
DIST_TAG=$(.github/workflows/guess-dist-tag.sh)
51+
52+
echo "FULL_VERSION=FULL_VERSION" >> "$GITHUB_OUTPUT"
53+
echo "DIST_TAG=$DIST_TAG" >> "$GITHUB_OUTPUT"
54+
55+
- name: "Run: make doc"
56+
run: |
57+
make doc
58+
59+
- name: "Echo info"
60+
env:
61+
DIST_TAG: ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
62+
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
63+
run: |
64+
echo "::notice file=lib/package.json::Will be published to \
65+
[GitHub Packages](https://github.com/opentdf/web-sdk/pkgs/npm/client) \
66+
as $DIST_TAG \
67+
with version=[$FULL_VERSION]"
68+
69+
- name: "Publish to GitHub Packages"
70+
env:
71+
DIST_TAG: ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
72+
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
73+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
run: |
75+
bash scripts/deliver-to-npm-registry.sh "$FULL_VERSION" "$DIST_TAG"
76+
77+
- name: "Echo info to Run Summary"
78+
run: |
79+
{
80+
echo "- [Client Library](https://github.com/opentdf/web-sdk/pkgs/npm/client)"
81+
echo "- [Command Line Tool](https://github.com/opentdf/web-sdk/pkgs/npm/cli)"
82+
} >>"$GITHUB_STEP_SUMMARY"
83+
84+
- name: "Publish documentation to gh-pages"
85+
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4.7.3
86+
with:
87+
branch: gh-pages
88+
folder: lib/dist/docs
89+
90+
deliver-npmjs:
91+
runs-on: ubuntu-latest
92+
needs: deliver-ghp
93+
steps:
94+
- name: "Checkout repo"
95+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96+
97+
- name: "Setup node"
98+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
99+
100+
with:
101+
node-version: "22"
102+
registry-url: "https://registry.npmjs.org"
103+
104+
- name: "Run: make all"
105+
run: |
106+
make all
107+
108+
- name: "Publish to npmjs"
109+
env:
110+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
111+
FULL_VERSION: ${{ needs.deliver-ghp.outputs.FULL_VERSION }}
112+
DIST_TAG: ${{ needs.deliver-ghp.outputs.DIST_TAG }}
113+
run: |
114+
bash scripts/deliver-to-npm-registry.sh "$FULL_VERSION" "$DIST_TAG"
115+
116+
- name: "Echo info to Run Summary"
117+
env:
118+
FULL_VERSION: ${{ needs.deliver-ghp.outputs.FULL_VERSION }}
119+
run: |
120+
{
121+
echo "- [Client Library](https://www.npmjs.com/package/@opentdf/sdk/v/$FULL_VERSION)"
122+
echo "- [Command Line Tool](https://www.npmjs.com/package/@opentdf/ctl/v/FULL_VERSION)"
123+
echo "- [unpkg](https://unpkg.com/browse/@opentdf/sdk@$FULL_VERSION)"
124+
} >>"$GITHUB_STEP_SUMMARY"

.github/workflows/publish-to.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Release"
2+
3+
on:
4+
workflow_call: {}
5+
push:
6+
branches:
7+
- main
8+
- "release/*"
9+
10+
# Default empty permissions for all jobs
11+
permissions: {}
12+
13+
jobs:
14+
release-please:
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
uses: opentdf/platform/.github/workflows/reusable_release-please.yaml@main

scripts/deliver-to-npm-registry.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# Validate that version number is same across all expected files
3+
4+
set -exuo pipefail
5+
6+
version="${1%%+*}"
7+
tag="${2}"
8+
9+
cd lib
10+
file=src/version.ts
11+
if ! sed "s/export const version = \'[^']\{1,\}\';\$/export const version = \'${version}\';/" "${file}" >"${file}.tmp"; then
12+
echo "Failed to insert version [${version}] into file [$file]"
13+
exit 1
14+
fi
15+
mv "${file}.tmp" "${file}"
16+
17+
npm version --no-git-tag-version --allow-same-version "$version"
18+
npm publish --access public --tag "$tag"
19+
20+
# Wait for npm publish to go through...
21+
sleep 5
22+
23+
cd "../cli"
24+
npm version --no-git-tag-version --allow-same-version "$version"
25+
npm uninstall "@opentdf/sdk"
26+
npm install "@opentdf/sdk@$version"
27+
npm publish --access public --tag "$tag"
28+
29+
if [[ "$GITHUB_STEP_SUMMARY" ]]; then
30+
echo "### Published ${version} (${tag})" >>"$GITHUB_STEP_SUMMARY"
31+
fi

0 commit comments

Comments
 (0)