-
Notifications
You must be signed in to change notification settings - Fork 5
164 lines (139 loc) · 6.14 KB
/
release.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Publish package on release branch if it's tagged with 'v*'
name: release
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branch: [main, master]
tags:
- 'v*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
release:
runs-on: ubuntu-18.04
strategy:
matrix:
python-versions: ['3.8']
# map step outputs to job outputs so they can be share among jobs
outputs:
package_version: ${{ steps.variables_step.outputs.package_version }}
package_name: ${{ steps.variables_step.outputs.package_name }}
repo_name: ${{ steps.variables_step.outputs.repo_name }}
repo_owner: ${{ steps.variables_step.outputs.repo_owner }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: build change log
id: build_changelog
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox-gh-actions poetry
# declare package_version, repo_owner, repo_name, package_name so you may use it in web hooks.
- name: Declare variables for convenient use
id: variables_step
run: |
echo "::set-output name=repo_owner::${GITHUB_REPOSITORY%/*}"
echo "::set-output name=repo_name::${GITHUB_REPOSITORY#*/}"
echo "::set-output name=package_name::`poetry version | awk '{print $1}'`"
echo "::set-output name=package_version::`poetry version --short`"
shell: bash
- name: publish documentation
run: |
poetry install -E dev
poetry run mkdocs build
git config --global user.name Docs deploy
git config --global user.email [email protected]
poetry run mike deploy -p -f --ignore `poetry version --short` latest
poetry run mike set-default -p `poetry version --short`
- name: Build wheels and source tarball
run: |
poetry lock
poetry build
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: ${{ steps.build_changelog.outputs.changelog }}
draft: false
prerelease: false
- name:
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
notification:
needs: release
if: always()
runs-on: ubuntu-latest
steps:
- uses: martialonline/workflow-status@v2
id: check
- name: build success notification via email
if: ${{ steps.check.outputs.status == 'success' }}
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.BUILD_NOTIFY_MAIL_SERVER }}
server_port: ${{ secrets.BUILD_NOTIFY_MAIL_PORT }}
username: ${{ secrets.BUILD_NOTIFY_MAIL_FROM }}
password: ${{ secrets.BUILD_NOTIFY_MAIL_PASSWORD }}
from: build-bot
to: ${{ secrets.BUILD_NOTIFY_MAIL_RCPT }}
subject: ${{ needs.release.outputs.package_name }}.${{ needs.release.outputs.package_version}} build successfully
convert_markdown: true
html_body: |
## Build Success
${{ needs.release.outputs.package_name }}.${{ needs.release.outputs.package_version }} is built and published to PYPI
## Change Details
${{ github.event.head_commit.message }}
For more information, please check change history at https://${{ needs.release.outputs.repo_owner }}.github.io/${{ needs.release.outputs.repo_name }}/${{ needs.release.outputs.package_version }}/latest/history
## Package Download
The pacakge is available at: https://pypi.org/project/${{ needs.release.outputs.package_name }}/
- name: build failure notification via email
if: ${{ steps.check.outputs.status == 'failure' }}
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.BUILD_NOTIFY_MAIL_SERVER }}
server_port: ${{ secrets.BUILD_NOTIFY_MAIL_PORT }}
username: ${{ secrets.BUILD_NOTIFY_MAIL_FROM }}
password: ${{ secrets.BUILD_NOTIFY_MAIL_PASSWORD }}
from: build-bot
to: ${{ secrets.BUILD_NOTIFY_MAIL_RCPT }}
subject: ${{ needs.release.outputs.package_name }}.${{ needs.release.outputs.package_version}} build failure
convert_markdown: true
html_body: |
## Change Details
${{ github.event.head_commit.message }}
## Status: ${{ steps.check.outputs.status }}
## View Log
https://github.com/${{ needs.release.outputs.repo_owner }}/${{ needs.release.outputs.repo_name }}/actions
# - name: Dingtalk Robot Notify
# if: always()
# uses: leafney/[email protected]
# env:
# DINGTALK_ACCESS_TOKEN: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
# DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
# with:
# msgtype: markdown
# title: CI Notification | Success
# text: |
# ### Build Success
# ${{ needs.release.outputs.package_version_full }} is built and published to test pypi
# ### Change History
# Please check change history at https://${{ needs.release.outputs.repo_owner }}.github.io/${{ needs.release.outputs.repo_name }}/history
# ### Package Download
# Please download the pacakge at: https://test.pypi.org/project/${{ needs.release.outputs.repo_name }}/