Skip to content

Commit

Permalink
ci: Publish prerelease packages in git-flow way (#468)
Browse files Browse the repository at this point in the history
* ci: Publish prerelease packages in git-flow way

---------

Co-authored-by: Thatchapon Unprasert <[email protected]>
  • Loading branch information
PoomSmart and Thatchapon Unprasert authored Nov 11, 2024
1 parent d095414 commit 516a934
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Manual Publish to NPM registry
name: Publish to NPM registry (Prerelease)

on:
workflow_dispatch:
Expand All @@ -11,6 +11,7 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
BUILD_NUMBER: ${{ github.ref_name }}.${{ github.run_number }}.${{ github.run_attempt }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js 20.x
Expand All @@ -19,4 +20,9 @@ jobs:
node-version: 20
- run: corepack enable pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm semantic-release
- run: |
PACKAGE_VERSION=$(node -pe "require('./package.json').version")
PACKAGE_VERSION="${PACKAGE_VERSION}-${BUILD_NUMBER}"
./ci/modify-package-version.sh $PACKAGE_VERSION
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
- run: pnpm publish --tag alpha --no-git-checks
15 changes: 15 additions & 0 deletions ci/modify-package-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

NEW_VERSION=$1

if [ -z "$NEW_VERSION" ]
then
echo "No new version supplied"
exit 1
fi

FILE='package.json'

jq --indent 4 --arg NEW_VERSION "$NEW_VERSION" '.version=$NEW_VERSION' $FILE > temp.json && mv temp.json $FILE

0 comments on commit 516a934

Please sign in to comment.