|
| 1 | +name: Publish |
| 2 | +on: |
| 3 | + # release: |
| 4 | + # types: [published] |
| 5 | + push: |
| 6 | + |
| 7 | +jobs: |
| 8 | + publish: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + release_number: ${{steps.get_latest_release_number.outputs.release_tag}} |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + steps: |
| 16 | + - name: Checkout xero-node repo |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + repository: XeroAPI/xero-node |
| 20 | + path: xero-node |
| 21 | + |
| 22 | + - name: Set up Node environment |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: 20 |
| 26 | + cache: 'npm' |
| 27 | + cache-dependency-path: '**/package-lock.json' |
| 28 | + registry-url: 'https://registry.npmjs.org' |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: npm ci |
| 32 | + working-directory: xero-node |
| 33 | + |
| 34 | + - name: Run Build |
| 35 | + run: npm run build |
| 36 | + working-directory: xero-node |
| 37 | + |
| 38 | + # - name: Fetch Latest release number |
| 39 | + # id: get_latest_release_number |
| 40 | + # run: | |
| 41 | + # latest_version=$(gh release view --json tagName --jq '.tagName') |
| 42 | + # echo "Latest release version is - $latest_version" |
| 43 | + # echo "::set-output name=release_tag::$latest_version" |
| 44 | + # working-directory: xero-node |
| 45 | + # env: |
| 46 | + # GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 47 | + |
| 48 | + # - name: Publish to npm |
| 49 | + # env: |
| 50 | + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 51 | + # run: npm publish |
| 52 | + # working-directory: xero-node |
| 53 | + |
| 54 | + - name: Always Succeed |
| 55 | + run: exit 0 |
| 56 | + |
| 57 | + notify-slack-on-success: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: publish |
| 60 | + if: success() |
| 61 | + steps: |
| 62 | + - name: Checkout xero-node repo |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + repository: XeroAPI/xero-node |
| 66 | + path: xero-node |
| 67 | + |
| 68 | + - name: Send slack notification on success |
| 69 | + uses: ./xero-node/.github/actions/notify-slack |
| 70 | + with: |
| 71 | + heading_text: "Publish job has succeeded !" |
| 72 | + alert_type: "thumbsup" |
| 73 | + job_status: "Success" |
| 74 | + XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} |
| 75 | + job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" |
| 76 | + button_type: "primary" |
| 77 | + package_version: ${{needs.publish.outputs.release_number}} |
| 78 | + repo_link: ${{github.server_url}}/${{github.repository}} |
| 79 | + |
| 80 | + notify-slack-on-failure: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + needs: publish |
| 83 | + if: failure() |
| 84 | + steps: |
| 85 | + - name: Checkout xero-node repo |
| 86 | + uses: actions/checkout@v4 |
| 87 | + with: |
| 88 | + repository: XeroAPI/xero-node |
| 89 | + path: xero-node |
| 90 | + |
| 91 | + - name: Send slack notification on failure |
| 92 | + uses: ./xero-node/.github/actions/notify-slack |
| 93 | + with: |
| 94 | + heading_text: "Publish job has failed !" |
| 95 | + alert_type: "alert" |
| 96 | + job_status: "Failed" |
| 97 | + XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} |
| 98 | + job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" |
| 99 | + button_type: "danger" |
| 100 | + package_version: ${{needs.publish.outputs.release_number}} |
| 101 | + repo_link: ${{github.server_url}}/${{github.repository}} |
0 commit comments