Prune NPM tags #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Prune NPM tags | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
jobs: | ||
prune: | ||
name: Prune NPM tags | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'latest' | ||
- name: Setup .npmrc file | ||
uses: actions/setup-node@v4 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Prune @pimlico/webhook tags | ||
run: | | ||
PACKAGE_NAME=$(jq -r '.name' package.json) | ||
npm view $PACKAGE_NAME dist-tags --json | jq -r 'to_entries | .[] | select(.key != "latest") | select(.key != "main") | select(.key != "next") | .key' | xargs -I % npm dist-tag rm $PACKAGE_NAME % | ||
working-directory: packages/webhook | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_UTILS_TOKEN }} | ||
- name: Deprecate @pimlico/webhook canary versions | ||
working-directory: packages/webhook | ||
run: | | ||
PACKAGE_NAME=$(jq -r '.name' package.json) | ||
TWO_DAYS_AGO=$(date --date='2 days ago' +%s) | ||
FOUR_DAYS_AGO=$(date --date='4 days ago' +%s) | ||
npm view $PACKAGE_NAME time --json | jq -c 'to_entries | .[] | select(.key | test("^0.0.0-.+$"))' \ | ||
| while read line; do | ||
VERSION=$(echo $line | jq -r '.key') | ||
TIME=$(echo $line | jq -r '.value') | ||
PUBLISH_DATE=$(date --date=$TIME +%s) | ||
if [ $PUBLISH_DATE -lt $FOUR_DAYS_AGO ]; then | ||
continue # skip versions older than 4 days to reduce the number of npm deprecate calls | ||
fi | ||
if [ $PUBLISH_DATE -lt $TWO_DAYS_AGO ]; then | ||
echo "Deprecate $PACKAGE_NAME@$VERSION" | ||
npm deprecate $PACKAGE_NAME@$VERSION "This canary version is deprecated because it is older than 2 days." || true | ||
echo "Deprecated $PACKAGE_NAME@$VERSION" | ||
fi | ||
done | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_UTILS_TOKEN }} | ||
run: | | ||
Check failure on line 59 in .github/workflows/prune-tags.yml GitHub Actions / Prune NPM tagsInvalid workflow file
|
||
PACKAGE_NAME=$(jq -r '.name' package.json) | ||
npm view $PACKAGE_NAME dist-tags --json | jq -r 'to_entries | .[] | select(.key != "latest") | select(.key != "main") | select(.key != "next") | .key' | xargs -I % npm dist-tag rm $PACKAGE_NAME % | ||
working-directory: packages/webhook | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_UTILS_TOKEN }} | ||
run: | | ||
PACKAGE_NAME=$(jq -r '.name' package.json) | ||
TWO_DAYS_AGO=$(date --date='2 days ago' +%s) | ||
FOUR_DAYS_AGO=$(date --date='4 days ago' +%s) | ||
npm view $PACKAGE_NAME time --json | jq -c 'to_entries | .[] | select(.key | test("^0.0.0-.+$"))' \ | ||
| while read line; do | ||
VERSION=$(echo $line | jq -r '.key') | ||
TIME=$(echo $line | jq -r '.value') | ||
PUBLISH_DATE=$(date --date=$TIME +%s) | ||
if [ $PUBLISH_DATE -lt $FOUR_DAYS_AGO ]; then | ||
continue # skip versions older than 4 days to reduce the number of npm deprecate calls | ||
fi | ||
if [ $PUBLISH_DATE -lt $TWO_DAYS_AGO ]; then | ||
echo "Deprecate $PACKAGE_NAME@$VERSION" | ||
npm deprecate $PACKAGE_NAME@$VERSION "This canary version is deprecated because it is older than 2 days." || true | ||
echo "Deprecated $PACKAGE_NAME@$VERSION" | ||
fi | ||
done | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_UTILS_TOKEN }} |