From 8e27ae37d1aaae68ab1dfd9a9bc5833b1485de80 Mon Sep 17 00:00:00 2001 From: Mark Faga Date: Mon, 4 Aug 2025 08:37:06 -0400 Subject: [PATCH] feat: add support for pre-releases in release script --- .github/workflows/release.yaml | 26 ++++++++++++++++++++++++-- README.md | 2 +- package.json | 6 +----- publish-prerelease.sh | 17 ----------------- publish-release.sh | 24 ------------------------ 5 files changed, 26 insertions(+), 49 deletions(-) delete mode 100755 publish-prerelease.sh delete mode 100755 publish-release.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 234cc2c..76e513d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,6 +9,8 @@ jobs: version-changed: ${{ steps.check.outputs.changed }} current-version: ${{ steps.check.outputs.current-version }} previous-version: ${{ steps.check.outputs.previous-version }} + is-prerelease: ${{ steps.check.outputs.is-prerelease }} + npm-tag: ${{ steps.check.outputs.npm-tag }} steps: - uses: actions/checkout@v4 with: @@ -30,6 +32,18 @@ jobs: echo "changed=false" >> $GITHUB_OUTPUT fi + # Check if this is a pre-release version + if [[ "$current_version" =~ -(alpha|beta|rc|dev|pre|canary|next) ]]; then + echo "is-prerelease=true" >> $GITHUB_OUTPUT + tag="$(echo "$current_version" | cut -d'-' -f2)" + echo "npm-tag=$tag" >> $GITHUB_OUTPUT + echo "Detected pre-release version with tag: $tag" + else + echo "is-prerelease=false" >> $GITHUB_OUTPUT + echo "npm-tag=latest" >> $GITHUB_OUTPUT + echo "Detected stable release version" + fi + build-and-publish: runs-on: ubuntu-latest needs: check-version @@ -48,14 +62,22 @@ jobs: registry-url: "https://registry.npmjs.org" - run: npm ci - run: npm run build - - run: npm publish --provenance --access public + - name: Publish to npm + run: | + if [ "${{ needs.check-version.outputs.is-prerelease }}" == "true" ]; then + npm publish --provenance --access public --tag ${{ needs.check-version.outputs.npm-tag }} + else + npm publish --provenance --access public + fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} create-release: runs-on: ubuntu-latest needs: [check-version, build-and-publish] - if: needs.build-and-publish.result == 'success' + if: + needs.build-and-publish.result == 'success' && needs.check-version.outputs.is-prerelease == + 'false' permissions: contents: write steps: diff --git a/README.md b/README.md index d1e8a7d..198bcf1 100644 --- a/README.md +++ b/README.md @@ -192,5 +192,5 @@ This script: To install the pre-release version: ```bash -npm install @reforge-com/javascript@pre +npm install @reforge-com/javascript ``` diff --git a/package.json b/package.json index 951a840..91de917 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@reforge-com/javascript", - "version": "0.0.0-pre.0", + "version": "0.0.0-pre.1", "description": "Feature Flags & Dynamic Configuration as a Service", "main": "dist/index.cjs", "module": "dist/index.mjs", @@ -21,7 +21,6 @@ "eslint-plugin-jest": "^26.8.0", "jest": "^29.0.0", "jest-fetch-mock": "^3.0.3", - "lint-staged": "^13.2.3", "prettier": "^3.0.0", "ts-jest": "^29.1.1", "ts-node": "^10.9.1", @@ -53,9 +52,6 @@ "url": "https://github.com/reforgehq/sdk-javascript/issues" }, "homepage": "https://github.com/reforgehq/sdk-javascript#readme", - "lint-staged": { - "**/*": "prettier --write --ignore-unknown" - }, "dependencies": { "uuid": "^9.0.1" }, diff --git a/publish-prerelease.sh b/publish-prerelease.sh deleted file mode 100755 index 32c898a..0000000 --- a/publish-prerelease.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e - -echo "Building and publishing pre-release version..." - -# Run tests -npm test - -# Build package -npm run build - -# Publish with pre tag -npm publish --tag pre - -echo "Pre-release published successfully! To install it, use:" -echo "npm install @reforge-com/javascript@pre" diff --git a/publish-release.sh b/publish-release.sh deleted file mode 100755 index 7c4c5b5..0000000 --- a/publish-release.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -e - -echo "Building and publishing standard release..." - -# Run tests -npm test - -# Build package -npm run build - -# Bump version -# This will trigger the version script which will: -# - run release tasks -# - rebuild to update version.ts -# - stage the updated version.ts -# Then npm will commit and tag, and postversion will push -npm version patch - -# Publish with latest tag -npm publish - -echo "Release published successfully!" \ No newline at end of file