@@ -2,10 +2,18 @@ name: Publish
2
2
on :
3
3
release :
4
4
types : [published]
5
+ pull_request :
6
+ branches :
7
+ - master
5
8
6
9
jobs :
7
10
publish :
8
11
runs-on : ubuntu-latest
12
+ outputs :
13
+ release_number : ${{steps.get_latest_release_number.outputs.release_tag}}
14
+ permissions :
15
+ contents : write
16
+ pull-requests : write
9
17
steps :
10
18
- name : Checkout xero-python repo
11
19
uses : actions/checkout@v4
@@ -27,13 +35,69 @@ jobs:
27
35
sudo pip install twine
28
36
working-directory : xero-python
29
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-python
45
+ env :
46
+ GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
47
+
30
48
- name : Build Package
31
49
run : python setup.py sdist
32
50
working-directory : xero-python
33
51
34
52
- name : Publish to PyPi
35
53
env :
36
54
TWINE_USERNAME : __token__
37
- TWINE_PASSWORD : ${{ secrets.PYPI_APIKEY }}
55
+ # TWINE_PASSWORD: ${{ secrets.PYPI_APIKEY }}
38
56
run : twine upload --repository-url https://test.pypi.org/legacy/ dist/*
39
57
working-directory : xero-python
58
+
59
+ notify-slack-on-success :
60
+ runs-on : ubuntu-latest
61
+ needs : publish
62
+ if : success()
63
+ steps :
64
+ - name : Checkout xero-node repo
65
+ uses : actions/checkout@v4
66
+ with :
67
+ repository : XeroAPI/xero-node
68
+ path : xero-node
69
+
70
+ - name : Send slack notification on success
71
+ uses : ./xero-node/.github/actions/notify-slack
72
+ with :
73
+ heading_text : " Publish job has succeeded !"
74
+ alert_type : " thumbsup"
75
+ job_status : " Success"
76
+ XERO_SLACK_WEBHOOK_URL : ${{secrets.XERO_SLACK_WEBHOOK_URL}}
77
+ job_url : " https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
78
+ button_type : " primary"
79
+ package_version : ${{needs.publish.outputs.release_number}}
80
+ repo_link : ${{github.server_url}}/${{github.repository}}
81
+
82
+ notify-slack-on-failure :
83
+ runs-on : ubuntu-latest
84
+ needs : publish
85
+ if : failure()
86
+ steps :
87
+ - name : Checkout xero-node repo
88
+ uses : actions/checkout@v4
89
+ with :
90
+ repository : XeroAPI/xero-node
91
+ path : xero-node
92
+
93
+ - name : Send slack notification on failure
94
+ uses : ./xero-node/.github/actions/notify-slack
95
+ with :
96
+ heading_text : " Publish job has failed !"
97
+ alert_type : " alert"
98
+ job_status : " Failed"
99
+ XERO_SLACK_WEBHOOK_URL : ${{secrets.XERO_SLACK_WEBHOOK_URL}}
100
+ job_url : " https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
101
+ button_type : " danger"
102
+ package_version : ${{needs.publish.outputs.release_number}}
103
+ repo_link : ${{github.server_url}}/${{github.repository}}
0 commit comments