-
Notifications
You must be signed in to change notification settings - Fork 26
106 lines (90 loc) · 2.94 KB
/
generate-release-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Generate Release Tag
on:
repository_dispatch:
types: [create-release-tag]
jobs:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10","3.11","3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Print python version
run: python --version
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run test
run: DEVELOPMENT_API_KEY=${{ secrets.DEVELOPMENT_API_KEY }} pytest -s --log-cli-level=DEBUG
send-test-result:
name: Slack Notification
needs: [testing]
if: always() && (needs.testing.result == 'success' || needs.testing.result == 'failure')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Slack Color
id: set_color
run: |
if [ "${{ needs.testing.result }}" == "success" ]; then
echo "color=good" >> $GITHUB_ENV
else
echo "color=danger" >> $GITHUB_ENV
fi
- name: Send Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_TITLE: "[xendi-python] CI pipeline for ${{ github.event.client_payload.version }}"
SLACK_MESSAGE: 'Test Result: ${{ needs.testing.result }}'
SLACK_COLOR: ${{ steps.set_color.outputs.color }}
publish-release-tag:
runs-on: ubuntu-latest
needs: [testing]
steps:
- uses: actions/checkout@v3
- name: Set the value in bash
id: parse-changelog
run: |
echo "changelog<<EOF" >> "$GITHUB_OUTPUT"
echo "${{ github.event.client_payload.changelog }}" | sed -e 's/%0A/\n/g' >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create Release
id: create-release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
with:
tag_name: ${{ github.event.client_payload.version }}
release_name: ${{ github.event.client_payload.version }}
body: ${{ steps.parse-changelog.outputs.changelog }}
draft: false
prerelease: false
publish-pypi:
needs: [publish-release-tag]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/xendit-python
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: '1.6.1'
- name: Build Package
run: |
poetry install
poetry build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1