diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 22a06a1..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Publish - -on: - push: - tags: - - 'v*' - -jobs: - publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - - - name: Install Yarn 3 (Berry) - run: npm install -g yarn@berry - - - name: Set up Yarn 3 - run: yarn set version berry - - - name: Install dependencies - run: yarn install --immutable - - - name: Extract version from latest Git tag - run: echo "Updating package.json version to latest tag" - - - name: Install jq - run: sudo apt-get install jq - - - name: Use version and add to package.json - run: | - TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) - VERSION=${TAG_NAME#*v.} - jq ".version = \"$VERSION\"" package.json > package.temp.json - mv package.temp.json package.json - env: - VERSION: $VERSION - - - name: Build - run: yarn build - - - name: Exclude source maps - run: rm -rf dist/**/*.map - - - name: Publish to NPM - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - - - name: Configure Git - run: | - git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" - git config --global user.name "maphel" - - - name: Commit updated package.json - run: | - git add package.json - git commit -m "Update package.json version to ${{ env.VERSION }}" - git push origin HEAD:${{ github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..047b042 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + + - name: Install Yarn 3 (Berry) + run: npm install -g yarn@berry + + - name: Set up Yarn 3 + run: yarn set version berry + + - name: Install dependencies + run: yarn install --immutable + + - name: Build + run: yarn build + + - name: Exclude source maps + run: rm -rf dist/**/*.map + + - name: Publish to NPM + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + + update-master-to-tagged-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout main + uses: actions/checkout@v3 + with: + ref: main + fetch-depth: 0 + + - name: Fetch tags + run: git fetch --tags + + - name: Extract version from latest Git tag or use default + run: | + TAG_NAME=$(git tag | tail -n 1) # Fetch the latest tag + if [ -z "$TAG_NAME" ]; then # Check if TAG_NAME is empty + echo "No tags found. Using default version 1.0.0." + VERSION="1.0.0" + else + VERSION=${TAG_NAME#*v} + fi + npm version $VERSION --no-git-tag-version + + - name: Commit and push updated package.json on main + run: | + git config --local user.email "${{ secrets.GIT_USER_EMAIL }}" + git config --local user.name "maphel" + git add package.json + git commit -m "Update package.json version to $VERSION on main" + git push origin main diff --git a/package.json b/package.json index 57d1a92..dc8a71f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maphel/classnames", - "version": "1.0.2", + "version": "1.0.9", "description": "A utility for generating class names", "main": "./dist/index.js", "types": "./dist/index.d.ts",