Skip to content

Commit

Permalink
Merge pull request strapi#16254 from strapi/chore/handle-dist-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaellis authored Apr 11, 2023
2 parents b7b92b2 + ac55981 commit 35ac944
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: 'Experimental Releases'
name: 'Publish Prerelease'

on:
workflow_dispatch:
inputs:
dist-tag:
description: 'The tag you want to publish to NPM'
default: 'experimental'

permissions:
contents: read # to fetch code (actions/checkout)
Expand All @@ -22,4 +26,4 @@ jobs:
- run: ./scripts/pre-publish.sh --yes
env:
VERSION: '0.0.0-experimental.${{ github.sha }}'
DIST_TAG: experimental
DIST_TAG: ${{ github.event.inputs.dist-tag }}
28 changes: 28 additions & 0 deletions .github/workflows/remove-dist-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Remove dist-tag from NPM'

on:
workflow_dispatch:
inputs:
dist-tag:
description: 'The tag you want to remove from NPM'
required: true

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
publish:
name: 'Publish'
runs-on: ubuntu-latest
if: github.repository == 'strapi/strapi'
steps:
- uses: actions/checkout@v3
- name: Setup npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
- uses: actions/setup-node@v3
with:
node-version: 16
- run: yarn
- run: ./scripts/remove-dist-tag
env:
DIST_TAG: ${{ github.event.inputs.dist-tag }}
25 changes: 25 additions & 0 deletions scripts/remove-dist-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Force start from root folder
cd "$(dirname "$0")/.."

set -e

distTag=$DIST_TAG

# trim distTag for whitespace at the start and end
distTag=$(echo "$distTag" | xargs)

if [[ -z "$distTag" ]]; then
echo "Please enter the dist-tag you want to remove"
read -r distTag
fi

# Check if dist tag is latest, beta, alpha or next and reject
if [[ "$distTag" == "latest" || "$distTag" == "beta" || "$distTag" == "alpha" || "$distTag" == "next" ]]; then
echo "You cannot remove the dist-tag $distTag"
exit 1
fi

# Run npm dist-tag rm $distTag on each package
./node_modules/.bin/lerna exec --no-private --stream -- "npm dist-tag rm \$LERNA_PACKAGE_NAME $distTag"

0 comments on commit 35ac944

Please sign in to comment.