chore: add inputs & remove-dist-tag script

This commit is contained in:
Josh 2023-03-30 14:23:17 +01:00
parent c58b405b44
commit e1dd3292f9
3 changed files with 62 additions and 1 deletions

View File

@ -2,6 +2,10 @@ name: 'Experimental Releases'
on:
workflow_dispatch:
inputs:
dist-tag:
description: 'The tag you want to remove from NPM'
default: 'experimental'
permissions:
contents: read # to fetch code (actions/checkout)
@ -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
.github/workflows/remove-dist-tag.yml vendored Normal file
View File

@ -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 }}

29
scripts/remove-dist-tag.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# Force start from root folder
cd "$(dirname "$0")/.."
set -e
distTag=$DIST_TAG
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
# Get all the packages
packages=$(./node_modules/.bin/lerna ls)
# Loop through the packages
for package in $packages; do
echo "Removing dist-tag $distTag from $package"
# Run npm dist-tag rm $distTag
npm dist-tag rm $package $distTag
done