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+ permissions :
56+ contents : read
57+ steps :
58+ - name : Checkout xero-ruby repo
59+ uses : actions/checkout@v4
60+ with :
61+ repository : XeroAPI/xero-ruby
62+ path : xero-ruby
63+
64+ - name : Send slack notification on success
65+ uses : ./xero-ruby/.github/actions/notify-slack
66+ with :
67+ heading_text : " Publish job has succeeded !"
68+ alert_type : " thumbsup"
69+ job_status : " Success"
70+ XERO_SLACK_WEBHOOK_URL : ${{secrets.XERO_SLACK_WEBHOOK_URL}}
71+ job_url : " https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
72+ button_type : " primary"
73+ package_version : ${{needs.publish.outputs.release_number}}
74+ repo_link : ${{github.server_url}}/${{github.repository}}
75+
76+ notify-slack-on-failure :
77+ runs-on : ubuntu-latest
78+ needs : publish
79+ if : failure()
80+ permissions :
81+ contents : read
82+ steps :
83+ - name : Checkout xero-ruby repo
84+ uses : actions/checkout@v4
85+ with :
86+ repository : XeroAPI/xero-ruby
87+ path : xero-ruby
88+
89+ - name : Send slack notification on failure
90+ uses : ./xero-ruby/.github/actions/notify-slack
91+ with :
92+ heading_text : " Publish job has failed !"
93+ alert_type : " alert"
94+ job_status : " Failed"
95+ XERO_SLACK_WEBHOOK_URL : ${{secrets.XERO_SLACK_WEBHOOK_URL}}
96+ job_url : " https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
97+ button_type : " danger"
98+ package_version : ${{needs.publish.outputs.release_number}}
99+ repo_link : ${{github.server_url}}/${{github.repository}}
0 commit comments