Skip to content

npm:unpublish

npm:unpublish #2

Workflow file for this run

# unpublish from npm if it's Github Release was deleted/unpublished.
name: npm:unpublish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
on:
release:
types:
- deleted
- unpublished
jobs:
npm-unpublish:
runs-on: ubuntu-latest
env:
REL_VERSION: ${{ github.event.release.tag_name }}
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup latest Node
uses: actions/setup-node@v4
with:
node-version: 'latest'
registry-url: 'https://registry.npmjs.org'
- name: Unpublish from npm
run: |
n_version=$(echo "$REL_VERSION" | sed 's/[^0-9.]*//g')
pckg_name="$(npm pkg get name | tr -d '"')"
versioned="$pckg_name"@"$n_version"
output=$(npm unpublish "$versioned")
printf "::notice title=Unpublished ${versioned}::Output: ${output}"