From 73942799c0298ebc53644eaaa04d503c14ed23f1 Mon Sep 17 00:00:00 2001 From: sangeet-joy_xero Date: Thu, 17 Apr 2025 14:56:59 +0530 Subject: [PATCH 1/4] added publish code --- .github/actions/notify-slack/action.yml | 103 +++++++++++++++++++++++ .github/workflows/publish.yml | 104 ++++++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 .github/actions/notify-slack/action.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/actions/notify-slack/action.yml b/.github/actions/notify-slack/action.yml new file mode 100644 index 00000000..add9673f --- /dev/null +++ b/.github/actions/notify-slack/action.yml @@ -0,0 +1,103 @@ +name: slack-alert-action +description: "Action to send slack payload to public-sdk-events channel" + +inputs: + heading_text: + required: true + description: "Heading of the slack payload" + alert_type: + required: true + description: "type of the slack alert" + job_status: + required: true + description: "status of the job" + XERO_SLACK_WEBHOOK_URL: + required: true + description: "webhook url for channel - public-sdk-events" + job_url: + required: true + description: "job run id link" + button_type: + required: true + description: "color for the check logs button" + package_version: + required: true + description: "released package version" + repo_link: + required: true + description: "link of the repo" + + +runs: + using: "composite" + + steps: + + - name: Send slack notification + id: slack + uses: slackapi/slack-github-action@v1.27.0 + env: + SLACK_WEBHOOK_URL: ${{inputs.XERO_SLACK_WEBHOOK_URL}} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + with: + payload: | + { + "blocks": [ + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "text", + "text": "${{inputs.heading_text}} ", + "style": { + "bold": true + } + }, + { + "type": "emoji", + "name": "${{inputs.alert_type}}" + } + ] + } + ] + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repository:* \n ${{inputs.repo_link}}" + }, + { + "type": "mrkdwn", + "text": "*Status:*\n ${{inputs.job_status}}" + }, + { + "type": "mrkdwn", + "text": "*Package Version:*\n ${{inputs.package_version}}" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Check the logs", + "emoji": true + }, + "style": "${{inputs.button_type}}", + "url": "${{inputs.job_url}}" + } + ] + } + ] + } diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..2f1cede9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,104 @@ +name: Publish +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + + outputs: + release_number: ${{steps.get_latest_release_number.outputs.release_tag}} + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout Xero-Java repo + uses: actions/checkout@v4 + with: + repository: XeroAPI/Xero-Java + path: Xero-Java + + - name: Set up JDK environment + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + cache: maven + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-passphrase: GPG_PASSPHRASE + + - name: Fetch Latest release number + id: get_latest_release_number + run: | + latest_version=$(gh release view --json tagName --jq '.tagName') + echo "Latest release version is - $latest_version" + echo "::set-output name=release_tag::$latest_version" + working-directory: Xero-Java + env: + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Import GPG Key + run: | + echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY}} + + - name: Publish to Maven + run: | + export GPG_TTY=$(tty) + mvn clean deploy -DskipTests=true + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + working-directory: Xero-Java + + notify-slack-on-success: + runs-on: ubuntu-latest + needs: publish + if: success() + steps: + - name: Checkout Xero-Java repo + uses: actions/checkout@v4 + with: + repository: XeroAPI/Xero-Java + path: Xero-Java + + - name: Send slack notification on success + uses: ./Xero-Java/.github/actions/notify-slack + with: + heading_text: "Publish job has succeeded !" + alert_type: "thumbsup" + job_status: "Success" + XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} + job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + button_type: "primary" + package_version: ${{needs.publish.outputs.release_number}} + repo_link: ${{github.server_url}}/${{github.repository}} + + notify-slack-on-failure: + runs-on: ubuntu-latest + needs: publish + if: failure() + steps: + - name: Checkout Xero-Java repo + uses: actions/checkout@v4 + with: + repository: XeroAPI/Xero-Java + path: Xero-Java + + - name: Send slack notification on failure + uses: ./Xero-Java/.github/actions/notify-slack + with: + heading_text: "Publish job has failed !" + alert_type: "alert" + job_status: "Failed" + XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} + job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + button_type: "danger" + package_version: ${{needs.publish.outputs.release_number}} + repo_link: ${{github.server_url}}/${{github.repository}} From d0e4e84a46bdb4baf6222a16b0ad70a27e3b2893 Mon Sep 17 00:00:00 2001 From: sangeet-joy_xero Date: Mon, 21 Apr 2025 13:08:49 +0530 Subject: [PATCH 2/4] added permissions --- .github/workflows/publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2f1cede9..e3c9b792 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -61,6 +61,8 @@ jobs: runs-on: ubuntu-latest needs: publish if: success() + permissions: + contents: read steps: - name: Checkout Xero-Java repo uses: actions/checkout@v4 @@ -84,6 +86,8 @@ jobs: runs-on: ubuntu-latest needs: publish if: failure() + permissions: + contents: read steps: - name: Checkout Xero-Java repo uses: actions/checkout@v4 From 3aabba56e56211bd6534d3a18d209212aa23e778 Mon Sep 17 00:00:00 2001 From: sangeet-joy_xero Date: Tue, 22 Apr 2025 12:38:17 +0530 Subject: [PATCH 3/4] testing publishing --- .github/workflows/publish.yml | 120 +++++++++++++++++----------------- pom.xml | 2 +- 2 files changed, 62 insertions(+), 60 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e3c9b792..2b197600 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,14 +1,16 @@ name: Publish on: - release: - types: [published] + push: +# on: +# release: +# types: [published] jobs: publish: runs-on: ubuntu-latest - outputs: - release_number: ${{steps.get_latest_release_number.outputs.release_tag}} + # outputs: + # release_number: ${{steps.get_latest_release_number.outputs.release_tag}} permissions: contents: write pull-requests: write @@ -31,15 +33,15 @@ jobs: server-password: MAVEN_PASSWORD gpg-passphrase: GPG_PASSPHRASE - - name: Fetch Latest release number - id: get_latest_release_number - run: | - latest_version=$(gh release view --json tagName --jq '.tagName') - echo "Latest release version is - $latest_version" - echo "::set-output name=release_tag::$latest_version" - working-directory: Xero-Java - env: - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + # - name: Fetch Latest release number + # id: get_latest_release_number + # run: | + # latest_version=$(gh release view --json tagName --jq '.tagName') + # echo "Latest release version is - $latest_version" + # echo "::set-output name=release_tag::$latest_version" + # working-directory: Xero-Java + # env: + # GH_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Import GPG Key run: | @@ -57,52 +59,52 @@ jobs: GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} working-directory: Xero-Java - notify-slack-on-success: - runs-on: ubuntu-latest - needs: publish - if: success() - permissions: - contents: read - steps: - - name: Checkout Xero-Java repo - uses: actions/checkout@v4 - with: - repository: XeroAPI/Xero-Java - path: Xero-Java + # notify-slack-on-success: + # runs-on: ubuntu-latest + # needs: publish + # if: success() + # permissions: + # contents: read + # steps: + # - name: Checkout Xero-Java repo + # uses: actions/checkout@v4 + # with: + # repository: XeroAPI/Xero-Java + # path: Xero-Java - - name: Send slack notification on success - uses: ./Xero-Java/.github/actions/notify-slack - with: - heading_text: "Publish job has succeeded !" - alert_type: "thumbsup" - job_status: "Success" - XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} - job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" - button_type: "primary" - package_version: ${{needs.publish.outputs.release_number}} - repo_link: ${{github.server_url}}/${{github.repository}} + # - name: Send slack notification on success + # uses: ./Xero-Java/.github/actions/notify-slack + # with: + # heading_text: "Publish job has succeeded !" + # alert_type: "thumbsup" + # job_status: "Success" + # XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} + # job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + # button_type: "primary" + # package_version: ${{needs.publish.outputs.release_number}} + # repo_link: ${{github.server_url}}/${{github.repository}} - notify-slack-on-failure: - runs-on: ubuntu-latest - needs: publish - if: failure() - permissions: - contents: read - steps: - - name: Checkout Xero-Java repo - uses: actions/checkout@v4 - with: - repository: XeroAPI/Xero-Java - path: Xero-Java + # notify-slack-on-failure: + # runs-on: ubuntu-latest + # needs: publish + # if: failure() + # permissions: + # contents: read + # steps: + # - name: Checkout Xero-Java repo + # uses: actions/checkout@v4 + # with: + # repository: XeroAPI/Xero-Java + # path: Xero-Java - - name: Send slack notification on failure - uses: ./Xero-Java/.github/actions/notify-slack - with: - heading_text: "Publish job has failed !" - alert_type: "alert" - job_status: "Failed" - XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} - job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" - button_type: "danger" - package_version: ${{needs.publish.outputs.release_number}} - repo_link: ${{github.server_url}}/${{github.repository}} + # - name: Send slack notification on failure + # uses: ./Xero-Java/.github/actions/notify-slack + # with: + # heading_text: "Publish job has failed !" + # alert_type: "alert" + # job_status: "Failed" + # XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} + # job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + # button_type: "danger" + # package_version: ${{needs.publish.outputs.release_number}} + # repo_link: ${{github.server_url}}/${{github.repository}} diff --git a/pom.xml b/pom.xml index 88e3193d..f7515695 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ xero-java jar xero-java - 10.0.0 + 10.0.0-alpha.1 https://github.com/XeroAPI/Xero-Java This is the official Java SDK for Xero API From c275090e4dacf747c4f017adc6c189f9dc26626c Mon Sep 17 00:00:00 2001 From: sangeet-joy_xero Date: Tue, 22 Apr 2025 13:18:46 +0530 Subject: [PATCH 4/4] reverted the version changes --- .github/workflows/publish.yml | 120 +++++++++++++++++----------------- pom.xml | 2 +- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2b197600..e3c9b792 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,16 +1,14 @@ name: Publish on: - push: -# on: -# release: -# types: [published] + release: + types: [published] jobs: publish: runs-on: ubuntu-latest - # outputs: - # release_number: ${{steps.get_latest_release_number.outputs.release_tag}} + outputs: + release_number: ${{steps.get_latest_release_number.outputs.release_tag}} permissions: contents: write pull-requests: write @@ -33,15 +31,15 @@ jobs: server-password: MAVEN_PASSWORD gpg-passphrase: GPG_PASSPHRASE - # - name: Fetch Latest release number - # id: get_latest_release_number - # run: | - # latest_version=$(gh release view --json tagName --jq '.tagName') - # echo "Latest release version is - $latest_version" - # echo "::set-output name=release_tag::$latest_version" - # working-directory: Xero-Java - # env: - # GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Fetch Latest release number + id: get_latest_release_number + run: | + latest_version=$(gh release view --json tagName --jq '.tagName') + echo "Latest release version is - $latest_version" + echo "::set-output name=release_tag::$latest_version" + working-directory: Xero-Java + env: + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Import GPG Key run: | @@ -59,52 +57,52 @@ jobs: GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} working-directory: Xero-Java - # notify-slack-on-success: - # runs-on: ubuntu-latest - # needs: publish - # if: success() - # permissions: - # contents: read - # steps: - # - name: Checkout Xero-Java repo - # uses: actions/checkout@v4 - # with: - # repository: XeroAPI/Xero-Java - # path: Xero-Java + notify-slack-on-success: + runs-on: ubuntu-latest + needs: publish + if: success() + permissions: + contents: read + steps: + - name: Checkout Xero-Java repo + uses: actions/checkout@v4 + with: + repository: XeroAPI/Xero-Java + path: Xero-Java - # - name: Send slack notification on success - # uses: ./Xero-Java/.github/actions/notify-slack - # with: - # heading_text: "Publish job has succeeded !" - # alert_type: "thumbsup" - # job_status: "Success" - # XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} - # job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" - # button_type: "primary" - # package_version: ${{needs.publish.outputs.release_number}} - # repo_link: ${{github.server_url}}/${{github.repository}} + - name: Send slack notification on success + uses: ./Xero-Java/.github/actions/notify-slack + with: + heading_text: "Publish job has succeeded !" + alert_type: "thumbsup" + job_status: "Success" + XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} + job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + button_type: "primary" + package_version: ${{needs.publish.outputs.release_number}} + repo_link: ${{github.server_url}}/${{github.repository}} - # notify-slack-on-failure: - # runs-on: ubuntu-latest - # needs: publish - # if: failure() - # permissions: - # contents: read - # steps: - # - name: Checkout Xero-Java repo - # uses: actions/checkout@v4 - # with: - # repository: XeroAPI/Xero-Java - # path: Xero-Java + notify-slack-on-failure: + runs-on: ubuntu-latest + needs: publish + if: failure() + permissions: + contents: read + steps: + - name: Checkout Xero-Java repo + uses: actions/checkout@v4 + with: + repository: XeroAPI/Xero-Java + path: Xero-Java - # - name: Send slack notification on failure - # uses: ./Xero-Java/.github/actions/notify-slack - # with: - # heading_text: "Publish job has failed !" - # alert_type: "alert" - # job_status: "Failed" - # XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} - # job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" - # button_type: "danger" - # package_version: ${{needs.publish.outputs.release_number}} - # repo_link: ${{github.server_url}}/${{github.repository}} + - name: Send slack notification on failure + uses: ./Xero-Java/.github/actions/notify-slack + with: + heading_text: "Publish job has failed !" + alert_type: "alert" + job_status: "Failed" + XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} + job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + button_type: "danger" + package_version: ${{needs.publish.outputs.release_number}} + repo_link: ${{github.server_url}}/${{github.repository}} diff --git a/pom.xml b/pom.xml index f7515695..88e3193d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ xero-java jar xero-java - 10.0.0-alpha.1 + 10.0.0 https://github.com/XeroAPI/Xero-Java This is the official Java SDK for Xero API