-
Notifications
You must be signed in to change notification settings - Fork 12
105 lines (91 loc) · 3.13 KB
/
build-test-deploy.yml
File metadata and controls
105 lines (91 loc) · 3.13 KB
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
name: GitHub Actions ACD Python SDK
on:
push:
branches: [ '**' ]
pull_request:
branches: [ master ]
jobs:
build_test:
name: Build on python ${{ matrix.python-version }} using ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test with tox
run: tox -e py
check_git:
name: Echo github vars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Echo GitHub Ref
run: echo "The GitHub Ref is ${{ github.ref }}."
- name: Echo Commit Message
run: echo "The Commit Message is ${{ github.event.head_commit.message }}."
- name: Echo GitHub Event Name
run: echo "The GitHub Event name is ${{ github.event_name }}."
release:
name: Deploy and publish
runs-on: ubuntu-latest
needs: build_test
if: "github.event_name == 'push' && github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'chore')"
steps:
- name: Setup Extensions
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '18'
- name: Install Semantic Release dependencies
run: |
pip3 install --user bump2version
npm install -g semantic-release
npm install -g @semantic-release/changelog
npm install -g @semantic-release/exec
npm install -g @semantic-release/git
npm install -g @semantic-release/github
- name: Get the next release from semantic release
id: next_release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "NEXT_RELEASE=$(npx semantic-release --dry-run | grep -oP "Published release \K[0-9]+\.[0-9]+\.[0-9]+")" >> $GITHUB_OUTPUT
- name: Publish to git releases and tags
if: ${{ steps.next_release.outputs.NEXT_RELEASE != null }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "The next release is ${{ steps.next_release.outputs.NEXT_RELEASE }}"
npx semantic-release
- name: Build project
if: ${{ steps.next_release.outputs.NEXT_RELEASE != null }}
run: |
pip install -U pip
pip install build
python -m build
- name: Publish to pypi
if: ${{ steps.next_release.outputs.NEXT_RELEASE != null }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USER }}
password: ${{ secrets.PYPI_PASSWORD }}
repository_url: https://upload.pypi.org/legacy/