From f889480cdfb4f1f925549948e8f3eb14f6beb438 Mon Sep 17 00:00:00 2001 From: sangeet-joy_xero Date: Thu, 26 Sep 2024 13:23:25 +0530 Subject: [PATCH] fetch release version step added --- .github/workflows/update-yaml-version.yml | 134 ++++++++++++---------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/.github/workflows/update-yaml-version.yml b/.github/workflows/update-yaml-version.yml index fd62a4462..2dc32d968 100644 --- a/.github/workflows/update-yaml-version.yml +++ b/.github/workflows/update-yaml-version.yml @@ -21,78 +21,86 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Update version of the yaml files + - name: Fetch Latest release number + id: get_latest_release_number run: | - ls - for file in xero_accounting.yaml xero_assets.yaml xero_bankfeeds.yaml xero_files.yaml xero-app-store.yaml xero-finance.yaml xero-identity.yaml xero-payroll-au.yaml xero-payroll-nz.yaml xero-payroll-uk.yaml xero-projects.yaml; do - yq eval ".info.version = \"10.1.0\"" -i "$file" - echo "updated version in $file" - done - head -n 20 xero_assets.yaml + latest_version=$(gh release view --json tagName --jq '.tagName') + echo "Latest release version is - $latest_version" + echo "releaseVersion=$latest_version" >> $GITHUB_OUTPUT + + # - name: Update version of the yaml files + # run: | + # ls + # for file in xero_accounting.yaml xero_assets.yaml xero_bankfeeds.yaml xero_files.yaml xero-app-store.yaml xero-finance.yaml xero-identity.yaml xero-payroll-au.yaml xero-payroll-nz.yaml xero-payroll-uk.yaml xero-projects.yaml; do + # yq eval ".info.version = \"10.1.0\"" -i "$file" + # echo "updated version in $file" + # done + # head -n 20 xero_assets.yaml - - name: Identify the branch name - id: identify_branch_name - run: | - branch_name='OAS-version-update-10.3.7' - echo "branchName=$branch_name" >> $GITHUB_OUTPUT - - name: Checkout branch - run: | - if git ls-remote --heads origin ${{steps.identify_branch_name.outputs.branchName}} | grep -q "refs/heads/${{steps.identify_branch_name.outputs.branchName}}"; then - echo "checking out existing branch" - git fetch origin > /dev/null 2>&1 - git checkout ${{steps.identify_branch_name.outputs.branchName}} - else - echo "branch does not exists, creating new branch" - echo "branchName *****>> ${{steps.identify_branch_name.outputs.branchName}}" - git checkout -b ${{steps.identify_branch_name.outputs.branchName}} - fi + # - name: Identify the branch name + # id: identify_branch_name + # run: | + # branch_name='OAS-version-update-10.3.7' + # echo "branchName=$branch_name" >> $GITHUB_OUTPUT - - name: Staging & commiting - id: detect-changes - run: | - CHANGES_DETECTED=$(git diff) - if [ -z "$CHANGES_DETECTED" ]; then - echo "no new changes, nothing to commit" - echo "changes_detected=false" >> $GITHUB_OUTPUT - else - echo "changes_detected=true" >> $GITHUB_OUTPUT - echo "running the git commands......" + # - name: Checkout branch + # run: | + # if git ls-remote --heads origin ${{steps.identify_branch_name.outputs.branchName}} | grep -q "refs/heads/${{steps.identify_branch_name.outputs.branchName}}"; then + # echo "checking out existing branch" + # git fetch origin > /dev/null 2>&1 + # git checkout ${{steps.identify_branch_name.outputs.branchName}} + # else + # echo "branch does not exists, creating new branch" + # echo "branchName *****>> ${{steps.identify_branch_name.outputs.branchName}}" + # git checkout -b ${{steps.identify_branch_name.outputs.branchName}} + # fi - git branch + # - name: Staging & commiting + # id: detect-changes + # run: | + # CHANGES_DETECTED=$(git diff) + # if [ -z "$CHANGES_DETECTED" ]; then + # echo "no new changes, nothing to commit" + # echo "changes_detected=false" >> $GITHUB_OUTPUT + # else + # echo "changes_detected=true" >> $GITHUB_OUTPUT + # echo "running the git commands......" + + # git branch - echo 'staging the changes' - git add --all + # echo 'staging the changes' + # git add --all - echo 'git status' - git diff + # echo 'git status' + # git diff - echo "git config setup" - git config --global user.name "Github Actions" - git config --global user.email "actions@github.com" + # echo "git config setup" + # git config --global user.name "Github Actions" + # git config --global user.email "actions@github.com" - echo 'commiting changes....' - git commit -m "chore: version update for all the yaml files" - fi + # echo 'commiting changes....' + # git commit -m "chore: version update for all the yaml files" + # fi - - name: Pushing the Branch - run: | - if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then - echo "pushing the code to ${{steps.identify_branch_name.outputs.branchName}}" - git branch - git push origin ${{steps.identify_branch_name.outputs.branchName}} - fi + # - name: Pushing the Branch + # run: | + # if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then + # echo "pushing the code to ${{steps.identify_branch_name.outputs.branchName}}" + # git branch + # git push origin ${{steps.identify_branch_name.outputs.branchName}} + # fi - - name: Create PR - run: | - if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then - echo "Creating PR in ${{steps.identify_branch_name.outputs.branchName}}" - gh pr create \ - --title "OAS version update" \ - --base master \ - --head ${{steps.identify_branch_name.outputs.branchName}} \ - --body "chore: version update for all the yaml files" - fi - env: - GITHUB_TOKEN: ${{ github.token }} + # - name: Create PR + # run: | + # if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then + # echo "Creating PR in ${{steps.identify_branch_name.outputs.branchName}}" + # gh pr create \ + # --title "OAS version update" \ + # --base master \ + # --head ${{steps.identify_branch_name.outputs.branchName}} \ + # --body "chore: version update for all the yaml files" + # fi + # env: + # GITHUB_TOKEN: ${{ github.token }}