diff --git a/.github/actions/draft-release/script.js b/.github/actions/draft-release/script.js index 511cef3..08a39e1 100644 --- a/.github/actions/draft-release/script.js +++ b/.github/actions/draft-release/script.js @@ -31,13 +31,37 @@ module.exports = async ({ github, context, inputs }) => { } } + console.log("Getting the latest tag"); + const majorVersion = inputs.branchName.split(".")[0]; + const { data: tags } = await github.rest.repos.listTags({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + const latestTag = tags.find( + (tag) => + tag.name.startsWith(`${majorVersion}.`) && !tag.name.includes("-beta"), + ); + if (latestTag) { + console.log(`Found latest tag: ${latestTag.name}`); + } else { + console.log(`No matching tags found for major version ${majorVersion}`); + } + console.log(`Creating a new untagged release for ${inputs.branchName}`); + const { data: notes } = await github.rest.repos.generateReleaseNotes({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: tagName, + target_commitish: inputs.branchName, + previous_tag_name: latestTag?.name, + }); await github.rest.repos.createRelease({ owner: context.repo.owner, repo: context.repo.repo, tag_name: tagName, name: `Unreleased [${inputs.branchName}]`, + body: notes.body, draft: true, - generate_release_notes: true, + target_commitish: inputs.branchName, }); }; diff --git a/.github/actions/set-release-tag/action.yml b/.github/actions/pre-release/action.yml similarity index 87% rename from .github/actions/set-release-tag/action.yml rename to .github/actions/pre-release/action.yml index abc6980..187b800 100644 --- a/.github/actions/set-release-tag/action.yml +++ b/.github/actions/pre-release/action.yml @@ -1,5 +1,5 @@ -name: "Set Release Tag" -description: "Updates the tag of specific release" +name: "Pre-Release" +description: "Pre-release the draft release" inputs: branch_name: @@ -17,7 +17,7 @@ outputs: runs: using: "composite" steps: - - name: Set release tag + - name: Create/Update the pre-release uses: actions/github-script@v6 id: set-release-tag with: diff --git a/.github/actions/pre-release/script.js b/.github/actions/pre-release/script.js new file mode 100644 index 0000000..1d312ec --- /dev/null +++ b/.github/actions/pre-release/script.js @@ -0,0 +1,28 @@ +module.exports = async ({ github, context, inputs }) => { + const draftTagName = `unreleased[${inputs.branchName}]`; + + const releases = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + + const release = releases.data.find( + (release) => release.tag_name == draftTagName && release.draft, + ); + if (!release) { + throw new Error("Draft release not found!"); + } + + console.log("Updating the draft release..."); + github.rest.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.id, + name: inputs.tagName, + tag_name: inputs.tagName, + draft: false, + prerelease: true, + }); + + return release.id; +}; diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..7e01be1 --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,37 @@ +name: "Release" +description: "Release the pre-release release" + +inputs: + release_id: + description: "The id of the target release" + required: true + tag_name: + description: "The release version tag" + required: true + npm_auth_token: + description: "The NPM authentication token" + required: true + +runs: + using: "composite" + steps: + - name: Release the package + uses: actions/github-script@v6 + with: + script: | + const script = require('${{ github.action_path }}/script.js') + return await script({ + github, + context, + inputs: { + releaseId: '${{ inputs.release_id }}', + tagName: '${{ inputs.tag_name }}', + } + }) + + # - name: Unpublish the beta versions + # shell: bash + # env: + # NODE_AUTH_TOKEN: ${{ inputs.npm_auth_token }} + # MAJOR_VERSION: ${{ inputs.tag_name.split('.')[0] }} + # run: ${{ github.action_path }}/unpublish-beta-versions.sh diff --git a/.github/actions/release/script.js b/.github/actions/release/script.js new file mode 100644 index 0000000..a189259 --- /dev/null +++ b/.github/actions/release/script.js @@ -0,0 +1,59 @@ +module.exports = async ({ github, context, inputs }) => { + const majorVersion = inputs.tagName.split(".")[0]; + + // Get current release + const { data: release } = await github.rest.repos.getRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: inputs.releaseId, + }); + + console.log("Updating release tag..."); + await github.rest.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.id, + name: inputs.tagName, + tag_name: inputs.tagName, + draft: false, + prerelease: false, + }); + + // Cleanup beta releases + console.log("Cleaning up beta releases..."); + const { data: releases } = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + + for (const release of releases) { + if ( + release.tag_name.startsWith(`${majorVersion}.`) && + release.tag_name.includes("-beta") + ) { + console.log(`Deleting beta release: ${release.tag_name}`); + await github.rest.repos.deleteRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.id, + }); + } + } + + // Cleanup beta tags + console.log("Cleaning up beta tags..."); + const { data: tags } = await github.rest.repos.listTags({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + for (const tag of tags) { + if (tag.name.startsWith(`${majorVersion}.`) && tag.name.includes("-beta")) { + console.log(`Deleting beta tag: ${tag.name}`); + await github.rest.git.deleteRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `refs/tags/${tag.name}`, + }); + } + } +}; diff --git a/.github/actions/release/unpublish-beta-versions.sh b/.github/actions/release/unpublish-beta-versions.sh new file mode 100755 index 0000000..83043ef --- /dev/null +++ b/.github/actions/release/unpublish-beta-versions.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$MAJOR_VERSION" ]; then + echo "Error: MAJOR_VERSION environment variable is not set" + exit 1 +fi + +# Get all versions and store them in an array +versions=($(npm view @mtrdesign/krait-ui versions | tr -d "'[]," | tr " " "\n")) + +# Loop through each version +for version in "${versions[@]}"; do + # Check if version starts with provided major version and contains "beta" + if [[ $version =~ ^${MAJOR_VERSION}\. && $version =~ beta ]]; then + echo "Deleting version: $version" + npm unpublish -f "@mtrdesign/krait-ui@$version" + fi +done diff --git a/.github/actions/set-release-tag/script.js b/.github/actions/set-release-tag/script.js deleted file mode 100644 index 1a94707..0000000 --- a/.github/actions/set-release-tag/script.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = async ({ github, context, inputs }) => { - const releases = await github.rest.repos.listReleases({ - owner: context.repo.owner, - repo: context.repo.repo, - tag_name: "unreleased", - }); - let release = releases.data.find( - (release) => - release.draft == true && - release.tag_name === `unreleased[${inputs.branchName}]`, - ); - - if (release) { - console.log("Updating the draft release..."); - github.rest.repos.updateRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: release.id, - name: inputs.tagName, - tag_name: inputs.tagName, - draft: false, - prerelease: true, - }); - } else { - console.log("Creating a new pre-release..."); - release = github.rest.repos.createRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - name: inputs.tagName, - tag_name: inputs.tagName, - draft: false, - prerelease: true, - generate_release_notes: true, - }); - } - - return release.id; -}; diff --git a/.github/workflows/draft_release.yml b/.github/workflows/cd_draft_release.yml similarity index 90% rename from .github/workflows/draft_release.yml rename to .github/workflows/cd_draft_release.yml index 6052c45..764815c 100644 --- a/.github/workflows/draft_release.yml +++ b/.github/workflows/cd_draft_release.yml @@ -13,6 +13,7 @@ concurrency: jobs: draft-release: name: Draft Github Release + if: github.actor != 'mtrpackageversionsmanager[bot]' runs-on: ubuntu-22.04 steps: - name: Checkout diff --git a/.github/workflows/pre_release.yml b/.github/workflows/cd_pre_release.yml similarity index 50% rename from .github/workflows/pre_release.yml rename to .github/workflows/cd_pre_release.yml index 075a1a2..840374c 100644 --- a/.github/workflows/pre_release.yml +++ b/.github/workflows/cd_pre_release.yml @@ -18,7 +18,7 @@ env: NODE_VERSION: "20.16.0" concurrency: - group: release + group: release-${{ github.ref_name }} cancel-in-progress: false permissions: @@ -26,7 +26,7 @@ permissions: jobs: check_branch: - name: Check the release branch + name: Check the Release Branch runs-on: ubuntu-22.04 outputs: major_version: ${{ steps.extract_major_version.outputs.version }} @@ -48,14 +48,14 @@ jobs: echo "version=$MAJOR_VERSION" >> "$GITHUB_OUTPUT" echo "Extracted major version: $MAJOR_VERSION" - pre_release: - name: Create Pre-Release + set_version: + name: Set Package Version runs-on: ubuntu-22.04 needs: [check_branch] outputs: - release_id: ${{ steps.update-release.outputs.release_id }} + version: ${{ steps.pre_release_version.outputs.version }} steps: - - name: Get Token + - name: Get the github token id: get_workflow_token uses: peter-murray/workflow-application-token-action@v3 with: @@ -65,8 +65,6 @@ jobs: - name: Checkout the repo uses: actions/checkout@v4 with: - ref: main - lfs: false token: ${{ steps.get_workflow_token.outputs.token }} - name: Install NodeJS @@ -80,6 +78,7 @@ jobs: git config user.name "github-actions[bot]" - name: Ensure that the major version matches the branch + working-directory: krait-ui env: MAJOR_VERSION: ${{ needs.check_branch.outputs.major_version }} run: | @@ -92,99 +91,114 @@ jobs: fi - name: Update version in package.json - working-directory: krait-ui if: github.event.inputs.version-update != 'no update' - run: npm version $VERSION_UPDATE --no-git-tag-version + working-directory: krait-ui env: VERSION_UPDATE: ${{ github.event.inputs.version-update }} + run: npm version $VERSION_UPDATE --no-git-tag-version - - name: Set the version as pre-release(beta) - id: create_tag + - name: Set the version as pre-release(beta version) + id: pre_release_version working-directory: krait-ui env: GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} run: | - TAG=$(npm version prerelease --preid=beta) - echo "tag=$TAG" >> "$GITHUB_OUTPUT" + VERSION=$(npm version prerelease --preid=beta) + echo "version=$VERSION" >> "$GITHUB_OUTPUT" - # - name: Commit the version update - # env: - # TAG_NAME: ${{ steps.create_tag.outputs.tag }} - # run: | - # git commit -am "[GHA] Update package version to $TAG_NAME" - # git push + - name: Commit the version update + env: + VERSION: ${{ steps.pre_release_version.outputs.version }} + run: | + git commit -am "[GHA] Update package version to $VERSION" + git push + + build_ui: + name: Build UI Library + needs: [set_version] + runs-on: ubuntu-22.04 + steps: + - name: Checkout the repo + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "npm" + cache-dependency-path: "krait-ui/package-lock.json" + + - name: Install npm dependencies + working-directory: krait-ui + run: npm ci + + - name: Build FE assets + working-directory: krait-ui + run: npm run build + + - name: Zip the distribution build + working-directory: krait-ui + run: zip -9qry "distribution-package.zip" "./" -i "dist/*" "package.json" "package-lock.json" + + - uses: actions/upload-artifact@v4 + with: + name: distribution-package.zip + path: krait-ui/distribution-package.zip + + pre_release: + name: Create Pre-Release + runs-on: ubuntu-22.04 + needs: [set_version] + outputs: + release_id: ${{ steps.update-release.outputs.release_id }} + steps: + - name: Checkout the repo + uses: actions/checkout@v4 - name: Set pre-release tag id: update-release - uses: ./.github/actions/set-release-tag + uses: ./.github/actions/pre-release with: - # branch_name: ${{ github.ref_name }} - branch_name: 1.x - tag_name: ${{ steps.create_tag.outputs.tag }} - - # build_ui: - # name: Build UI Library - # needs: [pre_release] - # runs-on: ubuntu-20.04 - # steps: - # - name: Get Token - # id: get_workflow_token - # uses: peter-murray/workflow-application-token-action@v3 - # with: - # application_id: ${{ vars.GH_MTR_PACKAGE_VERSIONS_APP_ID }} - # application_private_key: ${{ secrets.GH_MTR_PACKAGE_VERSIONS_APP_SECRET }} - - # - name: Checkout the repo - # uses: actions/checkout@v4 - # with: - # ref: main - # lfs: false - # token: ${{ steps.get_workflow_token.outputs.token }} - - # - name: Install NodeJS - # uses: actions/setup-node@v4 - # with: - # node-version: ${{ env.NODE_VERSION }} - # registry-url: "https://registry.npmjs.org" - - # - name: Retrieve the npm dependencies cache - # uses: actions/cache@v4 - # id: node-modules-cache - # with: - # path: node_modules - # key: npm-dependencies-${{ runner.os }}-${{ hashFiles('krait-ui/package-lock.json') }} - # restore-keys: | - # npm-dependencies-${{ hashFiles('krait-ui/package-lock.json') }} - # npm-dependencies- - - # - name: Install npm dependencies - # if: steps.node-modules-cache.outputs.cache-hit != 'true' - # run: cd krait-ui && npm ci - - # - name: Build FE assets - # run: cd krait-ui && npm run build - - # - name: Zip the distribution build - # run: cd krait-ui && zip -9qry "distribution-package.zip" "./" -i "dist/*" "package.json" "package-lock.json" - - # - name: Upload an Asset in GitHub Release - # uses: actions/github-script@v6 - # with: - # script: | - # const {RELEASE_ID} = process.env - - # const fs = require('fs').promises; - # await github.rest.repos.uploadReleaseAsset({ - # name: 'distribution-package.zip', - # owner: context.repo.owner, - # repo: context.repo.repo, - # release_id: ${{ env.RELEASE_ID }}, - # data: await fs.readFile('./krait-ui/distribution-package.zip') - # }); - # env: - # RELEASE_ID: ${{ needs.prerelease.outputs.release_id }} - - # - name: Publish the NPM package - # run: cd krait-ui && npm publish --access public --tag dev - # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + branch_name: ${{ github.ref_name }} + tag_name: ${{ needs.set_version.outputs.version }} + + publish_npm_package: + name: Publish the UI NPM package + runs-on: ubuntu-22.04 + needs: [pre_release, build_ui] + steps: + - name: Checkout the repo + uses: actions/checkout@v4 + + - name: Download the distribution build + uses: actions/download-artifact@v4 + with: + name: distribution-package.zip + path: krait-ui + + - name: Unzip the distribution build + working-directory: krait-ui + run: unzip -n distribution-package.zip + + - name: Upload an Asset in GitHub Release + uses: actions/github-script@v6 + with: + script: | + const {RELEASE_ID} = process.env + + const fs = require('fs').promises; + await github.rest.repos.uploadReleaseAsset({ + name: 'distribution-package.zip', + owner: context.repo.owner, + repo: context.repo.repo, + release_id: ${{ env.RELEASE_ID }}, + data: await fs.readFile('./krait-ui/distribution-package.zip') + }); + env: + RELEASE_ID: ${{ needs.pre_release.outputs.release_id }} + + # - name: Publish the NPM package + # working-directory: krait-ui + # run: npm publish --access public --tag dev + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/cd_release.yml b/.github/workflows/cd_release.yml new file mode 100644 index 0000000..188bbd7 --- /dev/null +++ b/.github/workflows/cd_release.yml @@ -0,0 +1,199 @@ +name: Release Packages + +on: + release: + types: [released] + +env: + NODE_VERSION: "20.16.0" + PHP_VERSION: "8.2.22" + +permissions: + contents: write + pull-requests: write + +defaults: + run: + working-directory: ./krait-ui + +concurrency: + group: release + cancel-in-progress: false + +jobs: + bump_version: + runs-on: "ubuntu-20.04" + name: Build UI + outputs: + version_branch: ${{ steps.get-version-details.outputs.major_version}}.x + release_version: ${{ steps.get-clean-version.outputs.version }} + steps: + - name: Get Github token + id: get-github-token + uses: peter-murray/workflow-application-token-action@v3 + with: + application_id: ${{ vars.GH_MTR_PACKAGE_VERSIONS_APP_ID }} + application_private_key: ${{ secrets.GH_MTR_PACKAGE_VERSIONS_APP_SECRET }} + + - name: Get release title and tag + id: get-version-details + run: | + echo "release_title=${{ github.event.release.name }}" >> $GITHUB_OUTPUT + echo "release_tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + + # Extract major version (handles v1.2.3-beta.0 or 1.2.3-beta.0) + MAJOR_VERSION=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v\{0,1\}\([0-9]\+\)[^0-9].*/\1/') + echo "major_version=$MAJOR_VERSION" >> $GITHUB_OUTPUT + + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ steps.get-version-details.outputs.major_version}}.x + token: ${{ steps.get-github-token.outputs.token }} + + - name: Check release title format + env: + RELEASE_TITLE: ${{ steps.get-version-details.outputs.release_title }} + run: | + if [[ -z "$RELEASE_TITLE" ]]; then + echo "Release title cannot be empty" + exit 1 + fi + + TITLE_VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+(-alpha|-beta)?$" + if [[ ! $RELEASE_TITLE =~ $TITLE_VERSION_REGEX ]]; then + echo "Invalid release title format: $RELEASE_TITLE" + exit 1 + else + echo "Release title $RELEASE_TITLE is valid" + fi + + - name: Get the clean version + id: get-clean-version + env: + TAG_NAME: ${{ steps.get-version-details.outputs.tag_name }} + run: | + VERSION=$(echo "$TAG_NAME" | sed 's/^v//' | cut -d'-' -f1) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Update package.json version + env: + CLEAN_VERSION: ${{ steps.get-clean-version.outputs.version }} + run: | + npm version $CLEAN_VERSION + + - name: Commit version bump in different branch + id: create-release-branch + env: + CLEAN_VERSION: ${{ steps.get-clean-version.outputs.version }} + GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} + run: | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + + git add . + git commit -am "Bump version to $CLEAN_VERSION" + git push origin HEAD:$CLEAN_VERSION + + release: + name: Release Package + runs-on: ubuntu-22.04 + needs: [bump_version] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ needs.bump_version.outputs.version_branch }} + + - name: Download the production build + id: download-production-build + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs').promises; + const artifact_name = 'distribution-package.zip'; + const download_path = 'krait-ui/distribution-package.zip'; + + // Get the release assets + const release = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag: context.payload.release.tag_name + }); + + // Find the specific asset + const asset = release.data.assets.find(asset => asset.name === artifact_name); + if (!asset) throw new Error(`Asset ${artifact_name} not found in release`); + + // Download the asset + const response = await github.rest.repos.getReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + asset_id: asset.id, + headers: { + Accept: 'application/octet-stream' + } + }); + + // Save the file + await fs.writeFile(download_path, Buffer.from(response.data)); + console.log(`Downloaded ${artifact_name} to ${download_path}`); + + return asset.id + + - name: Update zip with new package.json + working-directory: krait-ui + run: | + zip -u distribution-package.zip package.json package-lock.json + + - name: Delete existing release asset + uses: actions/github-script@v6 + with: + script: | + const assetId = ${{ steps.download-production-build.outputs.result }} + + await github.rest.repos.deleteReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + asset_id: assetId + }); + + - name: Upload an Asset in GitHub Release + uses: actions/github-script@v6 + with: + script: | + const {RELEASE_ID} = process.env + + const fs = require('fs').promises; + await github.rest.repos.uploadReleaseAsset({ + name: 'distribution-package.zip', + owner: context.repo.owner, + repo: context.repo.repo, + release_id: ${{ env.RELEASE_ID }}, + data: await fs.readFile('./krait-ui/distribution-package.zip') + }); + env: + RELEASE_ID: ${{ github.event.release.id }} + + - name: Set pre-release tag + id: update-release + uses: ./.github/actions/release + with: + release_id: ${{ github.event.release.id }} + tag_name: ${{ needs.bump_version.outputs.release_version }} + node_auth_token: ${{ secrets.NPM_AUTH_TOKEN }} + + - name: Unzip the distribution build + working-directory: krait-ui + run: | + unzip -n distribution-package.zip + + # - name: Publish the NPM package + # run: npm publish --access public + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci_validation.yml similarity index 91% rename from .github/workflows/ci.yml rename to .github/workflows/ci_validation.yml index f6178c6..44c0d7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci_validation.yml @@ -31,10 +31,10 @@ jobs: - name: Install npm dependencies run: npm ci - - name: Run Prettier Check + - name: Run Prettier check run: npm run prettier - - name: Run Lint Check + - name: Run Lint check run: npm run lint - name: Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a40e87f..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Release Packages - -on: - release: - types: [published] - -env: - NODE_VERSION: "20.16.0" - PHP_VERSION: "8.2.22" - -permissions: - contents: write - pull-requests: write - -defaults: - run: - working-directory: ./krait-ui - -jobs: - build_ui: - runs-on: "ubuntu-20.04" - name: Build UI - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Get release title and tag - id: get_version_details - run: | - echo "RELEASE_TITLE=${{ github.event.release.name }}" >> $GITHUB_ENV - echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV - - - name: Check release title format - run: | - if [[ -z "$RELEASE_TITLE" ]]; then - echo "Release title cannot be empty" - exit 1 - fi - - TITLE_VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+(-alpha|-beta)?$" - if [[ ! $RELEASE_TITLE =~ $TITLE_VERSION_REGEX ]]; then - echo "Invalid release title format: $RELEASE_TITLE" - exit 1 - else - echo "Release title $RELEASE_TITLE is valid" - fi - - - name: Check release tag format - run: | - if [[ -z "$RELEASE_TAG" ]]; then - echo "Release tag cannot be empty" - exit 1 - fi - - TAG_VERSION_REGEX="^[0-9]+\.[0-9]+\.[0-9]+(-alpha|-beta)?$" - if [[ ! $RELEASE_TAG =~ $TAG_VERSION_REGEX ]]; then - echo "Invalid release tag format: $RELEASE_TAG" - exit 1 - else - echo "Release tag $RELEASE_TAG is valid" - fi - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Retrieve the npm dependencies cache - uses: actions/cache@v4 - id: node-modules-cache - with: - path: node_modules - key: npm-dependencies-${{ runner.os }}-${{ hashFiles('./krait/package-lock.json') }} - restore-keys: | - npm-dependencies-${{ hashFiles('./krait/package-lock.json') }} - npm-dependencies- - - - name: Install npm dependencies - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm ci - - - name: Update package.json version - id: update-package-version - run: | - npm version $RELEASE_TAG - - - name: Build UI - id: build-ui-job - run: npm run build - - - name: Config Github User - run: | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config user.name "github-actions[bot]" - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - id: create_pr - with: - branch: version-bump/${{ env.RELEASE_TAG }} - title: "Bump version to ${{ env.RELEASE_TAG }}" - body: "This PR bumps the version to ${{ env.RELEASE_TAG }}." - base: main - labels: | - automerge - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Automerge PR - uses: "pascalgn/automerge-action@v0.16.4" - id: automerge - with: - merge_error_fail: "true" - merge_delete_branch: "true" - merge_method: "rebase" - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - PULL_REQUEST: ${{ steps.create_pr.outputs.pull-request-number }} -# - name: Publish the NPM package -# run: npm publish --access public -# env: -# NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/krait-ui/package-lock.json b/krait-ui/package-lock.json index 42e19c8..f5b526e 100644 --- a/krait-ui/package-lock.json +++ b/krait-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mtrdesign/krait-ui", - "version": "1.0.9-beta", + "version": "1.0.9-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mtrdesign/krait-ui", - "version": "1.0.9-beta", + "version": "1.0.9-beta.1", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-free": "^6.5.2", diff --git a/krait-ui/package.json b/krait-ui/package.json index 88f60b2..c9ace46 100644 --- a/krait-ui/package.json +++ b/krait-ui/package.json @@ -1,6 +1,6 @@ { "name": "@mtrdesign/krait-ui", - "version": "1.0.9-beta", + "version": "1.0.9-beta.1", "repository": { "type": "git", "url": "git+https://github.com/mtrdesign/krait.git"