v0.1.2 #31
Workflow file for this run
This file contains hidden or 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: Publish Package | |
| on: | |
| release: | |
| types: [created] # Triggers when a new GitHub release is created | |
| jobs: | |
| publish-beta-and-stable: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| release_type: [beta, stable] # Runs for both beta and stable | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: latest | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Determine Version | |
| id: versioning | |
| run: | | |
| git fetch --tags | |
| RELEASE_VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "GitHub Release Version: $RELEASE_VERSION" | |
| if [[ "${{ matrix.release_type }}" == "beta" ]]; then | |
| echo "Release type: BETA" | |
| EXISTING_VERSIONS=$(npm view @bitte-ai/your-package versions --json | jq -r '.[]' || echo "") | |
| BETA_VERSION="${RELEASE_VERSION}-beta" | |
| if echo "$EXISTING_VERSIONS" | grep -q "\"${BETA_VERSION}\""; then | |
| BETA_COUNTER=1 | |
| BETA_VERSION="${RELEASE_VERSION}-beta.${BETA_COUNTER}" | |
| while echo "$EXISTING_VERSIONS" | grep -q "\"${BETA_VERSION}\""; do | |
| BETA_COUNTER=$((BETA_COUNTER + 1)) | |
| BETA_VERSION="${RELEASE_VERSION}-beta.${BETA_COUNTER}" | |
| done | |
| fi | |
| echo "VERSION=$BETA_VERSION" >> $GITHUB_ENV | |
| echo "NPM_TAG=beta" >> $GITHUB_ENV | |
| echo "REACT_VERSION=19" >> $GITHUB_ENV | |
| else | |
| echo "Release type: STABLE" | |
| echo "VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
| echo "NPM_TAG=latest" >> $GITHUB_ENV | |
| echo "REACT_VERSION=18" >> $GITHUB_ENV | |
| fi | |
| - name: Update package.json for React Version | |
| run: | | |
| if [ "${{ env.REACT_VERSION }}" = "19" ]; then | |
| jq '.peerDependencies.react = "^19.0.0" | | |
| .peerDependencies["react-dom"] = "^19.0.0" | | |
| .overrides["react-is"] = "19.0.0" | | |
| .devDependencies["@types/react"] = "^19.0.10" | | |
| .devDependencies["@types/react-dom"] = "^19.0.4"' package.json > temp.json && mv temp.json package.json | |
| else | |
| jq '.peerDependencies.react = "^18.2.0" | | |
| .peerDependencies["react-dom"] = "^18.2.0" | | |
| del(.overrides) | | |
| .devDependencies["@types/react"] = "^18.2.0" | | |
| .devDependencies["@types/react-dom"] = "^18.2.0"' package.json > temp.json && mv temp.json package.json | |
| fi | |
| - name: Install Correct React Version | |
| run: | | |
| echo "Installing React ${{ env.REACT_VERSION }}" | |
| pnpm add react@${{ env.REACT_VERSION }} react-dom@${{ env.REACT_VERSION }} --save-exact | |
| - name: Build | |
| run: pnpm run build | |
| - name: Set Version in package.json | |
| run: pnpm version ${{ env.VERSION }} --no-git-tag-version | |
| - name: Configure NPM Authentication | |
| run: | | |
| echo "@bitte-ai:registry=https://registry.npmjs.org/" > ~/.npmrc | |
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | |
| - name: Publish to NPM | |
| run: | | |
| echo "Publishing version ${{ env.VERSION }} with tag ${{ env.NPM_TAG }}" | |
| pnpm publish --access public --tag ${{ env.NPM_TAG }} --no-git-checks | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |