Skip to content

Commit dfc2dfd

Browse files
ci: add version validation to SDK npm deprecate/undeprecate workflows
1 parent 8796e4e commit dfc2dfd

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

.github/workflows/sdk-deprecate-npm.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,38 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
uses: actions/checkout@v4
18-
18+
1919
- name: Set up Node.js
2020
uses: actions/setup-node@v4
2121
with:
2222
node-version: '18'
2323
registry-url: 'https://registry.npmjs.org'
24-
24+
2525
- name: Authenticate to npm
2626
run: |
2727
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
28-
28+
29+
- name: Check if package version exists
30+
working-directory: packages/sdk
31+
run: |
32+
echo "Checking if version ${{ github.event.inputs.package_version }} exists..."
33+
if npm view @iexec/dataprotector@${{ github.event.inputs.package_version }} version > /dev/null 2>&1; then
34+
echo "Version ${{ github.event.inputs.package_version }} exists in registry"
35+
else
36+
echo "Version ${{ github.event.inputs.package_version }} does not exist in registry"
37+
echo "This might be a nightly/staging version that was never published to the public registry."
38+
echo "Available versions:"
39+
npm view @iexec/dataprotector versions --json | tail -10
40+
exit 1
41+
fi
42+
2943
- name: Deprecate package
3044
working-directory: packages/sdk
3145
run: |
3246
if [ -n "${{ github.event.inputs.package_version }}" ]; then
47+
echo "Deprecating @iexec/dataprotector@${{ github.event.inputs.package_version }}"
3348
npm deprecate @iexec/dataprotector@${{ github.event.inputs.package_version }} "deprecate ${{ github.event.inputs.package_version }}"
49+
echo " Successfully deprecated version ${{ github.event.inputs.package_version }}"
3450
else
3551
echo "Package version is not set"
3652
exit 1

.github/workflows/sdk-undeprecate-npm.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,38 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
uses: actions/checkout@v4
18-
18+
1919
- name: Set up Node.js
2020
uses: actions/setup-node@v4
2121
with:
2222
node-version: '18'
2323
registry-url: 'https://registry.npmjs.org'
24-
24+
2525
- name: Authenticate to npm
2626
run: |
2727
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
28-
28+
29+
- name: Check if package version exists
30+
working-directory: packages/sdk
31+
run: |
32+
echo "Checking if version ${{ github.event.inputs.package_version }} exists..."
33+
if npm view @iexec/dataprotector@${{ github.event.inputs.package_version }} version > /dev/null 2>&1; then
34+
echo "Version ${{ github.event.inputs.package_version }} exists in registry"
35+
else
36+
echo "Version ${{ github.event.inputs.package_version }} does not exist in registry"
37+
echo "This might be a nightly/staging version that was never published to the public registry."
38+
echo "Available versions:"
39+
npm view @iexec/dataprotector versions --json | tail -10
40+
exit 1
41+
fi
42+
2943
- name: Undeprecate package
3044
working-directory: packages/sdk
3145
run: |
3246
if [ -n "${{ github.event.inputs.package_version }}" ]; then
47+
echo "Removing deprecation from @iexec/dataprotector@${{ github.event.inputs.package_version }}"
3348
npm deprecate @iexec/dataprotector@${{ github.event.inputs.package_version }} ""
49+
echo "Successfully removed deprecation from version ${{ github.event.inputs.package_version }}"
3450
else
3551
echo "Package version is not set"
3652
exit 1

0 commit comments

Comments
 (0)