Skip to content

Commit 50783f4

Browse files
committed
Branch tag
1 parent 210958d commit 50783f4

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.github/workflows/publish.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,36 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0 # Récupère tout l'historique pour détecter la branche
20+
21+
- name: Get branch and determine npm tag
22+
id: config
23+
run: |
24+
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep -v HEAD | sed 's/.*origin\///' | head -n1 | xargs)
25+
echo "BRANCH=$BRANCH" >> $GITHUB_OUTPUT
26+
echo "Detected branch: $BRANCH"
27+
28+
# Mapping des branches vers les tags npm
29+
case "$BRANCH" in
30+
main|master)
31+
NPM_TAG="latest"
32+
;;
33+
quantum-prod)
34+
NPM_TAG="quantum"
35+
;;
36+
dev)
37+
NPM_TAG="dev"
38+
;;
39+
*)
40+
# Pour toutes les autres branches, normalise le nom
41+
# Remplace les caractères spéciaux par des tirets et met en minuscules
42+
NPM_TAG=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')
43+
;;
44+
esac
45+
46+
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_OUTPUT
47+
echo "Will publish with npm tag: $NPM_TAG"
1848
1949
- name: Setup Node.js
2050
uses: actions/setup-node@v4
@@ -30,4 +60,4 @@ jobs:
3060
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
3161

3262
- name: Publish to npm
33-
run: npm publish --access public
63+
run: npm publish --access public --tag ${{ steps.config.outputs.NPM_TAG }}

0 commit comments

Comments
 (0)