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