Skip to content

Commit 3873697

Browse files
committed
Updated publish config to not use access tokens anymore
1 parent 45b5b72 commit 3873697

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

.github/workflows/publish.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ defaults:
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
1115
steps:
1216
- name: Check Out Repo
1317
uses: actions/checkout@v6
@@ -18,6 +22,9 @@ jobs:
1822
registry-url: "https://registry.npmjs.org"
1923
node-version-file: ./src/.nvmrc
2024

25+
- name: Ensure specific npm version
26+
run: npm install -g npm@11.9.0
27+
2128
- name: Install dependencies
2229
run: npm ci
2330

@@ -50,20 +57,24 @@ jobs:
5057
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5158
NODE_ENV: production
5259

53-
- name: Publish Pongo package on NPM 📦
60+
- name: Publish packages on NPM 📦
5461
run: |
55-
VERSION=$(node -p "require('./package.json').version")
56-
if [[ $VERSION == *"beta"* ]]; then
57-
TAG="beta"
58-
elif [[ $VERSION == *"alpha"* ]]; then
59-
TAG="alpha"
60-
elif [[ $VERSION == *"rc"* ]]; then
61-
TAG="rc"
62-
else
63-
TAG="latest"
64-
fi
65-
npm publish --w @event-driven-io/pongo --tag $TAG
66-
continue-on-error: true
67-
env:
68-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
69-
NODE_ENV: production
62+
for pkg_dir in packages/*/; do
63+
[ -f "${pkg_dir}package.json" ] || { echo "⏭ ${pkg_dir} has no package.json — skipping"; continue; }
64+
65+
read -r pkg_name pkg_version pkg_private < <(node -p "
66+
const p = require('./${pkg_dir}package.json');
67+
[p.name, p.version, p.private ?? false].join(' ')
68+
")
69+
70+
[ "$pkg_private" = "true" ] && { echo "⏭ ${pkg_name}@${pkg_version} is private — skipping"; continue; }
71+
72+
tag=$(echo "$pkg_version" | sed -E 's/.*-(beta|alpha|rc)\..*/\1/; t; s/.*/latest/')
73+
74+
if npm view "${pkg_name}@${pkg_version}" version >/dev/null 2>&1; then
75+
echo "⏭ ${pkg_name}@${pkg_version} already published — skipping"
76+
else
77+
echo "📦 Publishing ${pkg_name}@${pkg_version}"
78+
npm publish -w "${pkg_dir}" --tag "$tag" --access public --provenance
79+
fi
80+
done

0 commit comments

Comments
 (0)