diff --git a/.github/workflows/checkPR.yml b/.github/workflows/checkPR.yml new file mode 100644 index 0000000..ae34c91 --- /dev/null +++ b/.github/workflows/checkPR.yml @@ -0,0 +1,30 @@ +# This workflow check current version and the latest tag version +# if current version and latest version is same than PR check fail +# if current version and latest version is not same than PR check pass + +name: PR Check + +on: + pull_request: + branches: + - master + +jobs: + pr-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get current version and tag + run: | + version="$(node -p "require('./package.json').version")" + tag="$(git describe --tag --abbrev=0 | cut -c 2-)" + if [ "$version" == "$tag" ]; then + echo "Current version and the recent tag version is same. Please update the version in package.json file." + exit 1; + else + echo "Current verions:$version Tag:$tag \nThis PR is ready to merge." + exit 0; + fi \ No newline at end of file diff --git a/.github/workflows/master.yml b/.github/workflows/onComment.yml similarity index 63% rename from .github/workflows/master.yml rename to .github/workflows/onComment.yml index 9c31054..30b90d5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/onComment.yml @@ -1,18 +1,16 @@ -# When any change is pushed on master, it triggers a beta -# version release with the @next tag -# -# When a tag is published, it triggers the release flow, -# which takes the version which is released and converts -# it into the @latest tag -name: Process master branch updates +# When issue is created with title "Deploy" and anybody +# comment "/deploy" in comment this workflow is triggered. +# This workflow publish the package in @next tag. + +name: Process master branch for @next tag on: - push: - branches: - - master + issue_comment: + types: [created] jobs: push-to-next: + if: ${{ github.event.issue.title == 'Deploy' && github.event.comment.body == '/deploy' && github.event.issue.state == 'open' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -26,27 +24,24 @@ jobs: node-version: '14.x' registry-url: 'https://npm.pkg.github.com' scope: '@bhoos' + - name: Install Dependencies and publish packages run: | yarn - yarn version --patch - yarn publish . --tag next version=$(node -p "require('./package.json').version") echo "RELEASE_VERSION=v${version}" >> $GITHUB_ENV + echo "ISSUE_NUMBER=${{github.event.issue.number}}" >> $GITHUB_ENV + git push && git push --tags + yarn clean && yarn build + yarn publish . --tag next env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build Changelog - id: github_release - uses: mikepenz/release-changelog-builder-action@v1 - with: - configuration: "workflow_config/config.json" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release for moving to production uses: ncipollo/release-action@v1 with: tag: ${{ env.RELEASE_VERSION }} - name: Release ${{ env.RELEASE_VERSION }} + name: Release ${{ env.RELEASE_VERSION }} (#${{ env.ISSUE_NUMBER }}) commit: master body: ${{steps.github_release.outputs.changelog}} draft: true diff --git a/.github/workflows/release.yml b/.github/workflows/onPublished.yml similarity index 50% rename from .github/workflows/release.yml rename to .github/workflows/onPublished.yml index 5024885..a1dc0dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/onPublished.yml @@ -1,9 +1,9 @@ # Promote staging version to production (latest) -name: Promote to Production +name: Promote to Production (@latest tag) on: release: - type: [published] + types: [published] jobs: production-release: @@ -18,10 +18,23 @@ jobs: - name: Publish release run: | + echo "ISSUE_NUMBER=$(echo $NUMBER | awk -F'[\#\)]' '{print $2}')" >> $GITHUB_ENV pkg=$(node -p "require('./package.json').name") version=$(node -p "require('./package.json').version") echo "Releasing ${pkg}@${version} to latest" # The following command doesn't work with `yarn tag` (2021-Jan-06) npm dist-tag add ${pkg}@${version} latest env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NUMBER: ${{github.event.release.name}} + # Close issue + - name: Close Issue + uses: peter-evans/close-issue@v1 + with: + issue-number: ${{ env.ISSUE_NUMBER }} + comment: This issue is tested and realeased. Auto-closing issue. + # Deletes any release marked as a draft + - name: Delete drafts + uses: hugo19941994/delete-draft-releases@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/package.json b/package.json index 31e8be5..af4b019 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bhoos/react-native-kit", - "version": "1.0.7", + "version": "1.0.8", "description": "Bhoos React Native Library", "main": "dist/index.js", "module": "es6/index.js", @@ -9,9 +9,7 @@ "clean": "rimraf dist && rimraf es6", "build:cjs": "tsc", "build:es6": "mkdir -p es6 && echo '{\"type\":\"module\"}' > es6/package.json && tsc --module es6 --outDir es6", - "build": "yarn build:cjs && yarn build:es6", - "prepublishOnly": "yarn clean && yarn build", - "postversion": "git push && git push --tags" + "build": "yarn build:cjs && yarn build:es6" }, "files": [ "dist", diff --git a/workflow_config/config.json b/workflow_config/config.json deleted file mode 100644 index 22b4541..0000000 --- a/workflow_config/config.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "categories": [ - { - "title": "## ๐Ÿš€ Features", - "labels": ["feature"] - }, - { - "title": "## ๐Ÿ› Fixes", - "labels": ["fix"] - }, - { - "title": "## ๐Ÿงช Tests", - "labels": ["test"] - } - ], - "sort": "ASC", - "template": "${{CHANGELOG}}\n\n
\nUncategorized\n\n${{UNCATEGORIZED}}\n
", - "pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}", - "empty_template": "- no changes", - "transformers": [ - { - "pattern": "[\\-\\*] (\\[(...|TEST|CI|SKIP)\\])( )?(.+?)\n(.+?[\\-\\*] )(.+)", - "target": "- $4\n - $6" - } - ], - "max_tags_to_fetch": 200, - "max_pull_requests": 200, - "max_back_track_time_days": 90, - "exclude_merge_branches": [ - "Owner/qa" - ] -} \ No newline at end of file