From 08684a3c0ed954b9f3963400a9f22ed0f14f53e8 Mon Sep 17 00:00:00 2001 From: Aman Chaturvedi Date: Tue, 12 Mar 2024 13:20:27 +0530 Subject: [PATCH] TP-39914 | generate release note --- .github/workflows/codePush.yml | 95 +++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/.github/workflows/codePush.yml b/.github/workflows/codePush.yml index cb2eb90f..e37952ae 100644 --- a/.github/workflows/codePush.yml +++ b/.github/workflows/codePush.yml @@ -46,20 +46,20 @@ jobs: echo "Set version to $VERSION" echo "buildNumber=$BUILD_NUMBER" >> $GITHUB_OUTPUT echo "Set buildNumber to $BUILD_NUMBER" - - name: Install yarn - run: npm install --global yarn - - name: Install appcenter cli - run: npm install -g appcenter-cli - - name: Install dependency - run: yarn - - name: AppCenter login - run: appcenter login --token ${{ secrets.APP_CENTER_LOGIN_TOKEN }} - - name: CodePush QA - if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA')) - run: yarn move:qa && appcenter codepush release-react -a nfa-navi.com/nfa-app -d Staging -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}" - - name: CodePush Prod - if: ((github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod')) - run: yarn move:prod && appcenter codepush release-react -a nfa-navi.com/nfa-app -d Production -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}" + # - name: Install yarn + # run: npm install --global yarn + # - name: Install appcenter cli + # run: npm install -g appcenter-cli + # - name: Install dependency + # run: yarn + # - name: AppCenter login + # run: appcenter login --token ${{ secrets.APP_CENTER_LOGIN_TOKEN }} + # - name: CodePush QA + # if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA')) + # run: yarn move:qa && appcenter codepush release-react -a nfa-navi.com/nfa-app -d Staging -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}" + # - name: CodePush Prod + # if: ((github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod')) + # run: yarn move:prod && appcenter codepush release-react -a nfa-navi.com/nfa-app -d Production -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}" create_release_tag: needs: generate @@ -72,14 +72,61 @@ jobs: token: ${{ secrets.MY_REPO_PAT }} submodules: recursive persist-credentials: true - - name: Create Release - id: create_release - uses: ncipollo/release-action@v1 + # - name: Create Release + # id: create_release + # uses: actions/create-release@latest + # env: + # GITHUB_TOKEN: ${{ secrets.MY_REPO_PAT }} # This token is provided by Actions, you do not need to create your own token + # with: + # tag_name: ${{ needs.generate.outputs.package_version }} + # release_name: ${{ needs.generate.outputs.package_version }} (build ${{ needs.generate.outputs.build_number }}) code push + # body: "" + # draft: false + # prerelease: false + + - name: Check if tag exists + id: check_tag + run: | + TAG_NAME="${{ needs.generate.outputs.package_version }}" + EXISTING_TAG=$(git ls-remote --tags origin refs/tags/$TAG_NAME) + if [[ -z "$EXISTING_TAG" ]]; then + echo "Tag $TAG_NAME does not exist." + echo "tag_exists=false" >> $GITHUB_ENV + else + echo "Tag $TAG_NAME already exists." + echo "tag_exists=true" >> $GITHUB_ENV + fi + + - name: Create and push tag + if: env.tag_exists == 'false' + run: | + TAG_NAME="${{ needs.generate.outputs.package_version }}" + # git config --local user.email "${{ github.actor }}@github.com" + git config --local user.name "${{ github.actor }}" + git tag $TAG_NAME + git push origin $TAG_NAME env: - GITHUB_TOKEN: ${{ secrets.MY_REPO_PAT }} # This token is provided by Actions, you do not need to create your own token - with: - tag: ${{ needs.generate.outputs.package_version }} - name: ${{ needs.generate.outputs.package_version }} (build ${{ needs.generate.outputs.build_number }}) code push - artifacts: "release.tar.gz,foo/*.txt" - bodyFile: "body.md" - generateReleaseNotes: true + GITHUB_TOKEN: ${{ secrets.MY_REPO_PAT }} + - name: Create release tag + run: | + TAG_NAME="${{ needs.generate.outputs.package_version }}" + BUILD_NUMBER="${{ needs.generate.outputs.build_number }}" + RELEASE_NAME="$TAG_NAME (build $BUILD_NUMBER) code push" + DESCRIPTION="${{ github.event.inputs.description }}" + REPO="navi-medici/address-verification-app" + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + + curl -X POST \ + -H "Authorization: token ${{ secrets.MY_REPO_PAT }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$TAG_NAME\", + \"target_commitish\": \"$BRANCH_NAME\", + \"name\": \"$RELEASE_NAME\", + \"body\": \"\", + \"draft\": false, + \"prerelease\": false, + \"generate_release_notes\": true + }" \ + "https://api.github.com/repos/$REPO/releases" + shell: bash