-
Notifications
You must be signed in to change notification settings - Fork 1
164 lines (146 loc) · 5.22 KB
/
ci.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
name: irissqlcli
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- released
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "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 }}
- name: Install requirements
run: |
pip install -U pip setuptools
pip install -r requirements-dev.txt
pip install -r requirements-iris.txt
pip install -e .
- uses: nick-fields/retry@v2
name: Run unit tests
with:
max_attempts: 3
command: pytest --container containers.intersystems.com/intersystems/iris-community:latest-em --lf
# - name: Run Linters
# if: matrix.python-version == '3.10'
# run: |
# black --check .
# autoflake -r irissqlcli
# - name: Coverage
# run: |
# coverage combine
# coverage report
# codecov
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1 origin '+refs/tags/*:refs/tags/*'
continue-on-error: true
- name: set version
id: set-version
run: |
VERSION=$(head -1 irissqlcli/__init__.py | cut -d '"' -f2)
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=b$(($(git tag -l "v${VERSION}b*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d b -f2)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/" irissqlcli/__init__.py
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Install requirements
run: |
pip install -U pip setuptools
pip install -r requirements-dev.txt
pip install -r requirements-iris.txt
pip install -e .
- name: Build Python package
run: ./scripts/build-dist.sh
- uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request'
with:
name: dist
path: dist/irissqlcli-${{ steps.set-version.outputs.version }}-py3-none-any.whl
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v1
if: github.event_name != 'pull_request'
with:
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: dist/irissqlcli-${{ steps.set-version.outputs.version }}-py3-none-any.whl
- name: Publish package
if: github.event_name != 'pull_request'
uses: pypa/gh-action-pypi-publish@release/v1.5
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker images
run: make push
- uses: actions/checkout@v3
if: github.event_name == 'release'
with:
ref: main
- name: Bump version
if: github.event_name == 'release'
run: |
git config --global user.name 'ProjectBot'
git config --global user.email '[email protected]'
VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
sed -ie "s/__version__ = .*/__version__ = \"$VERSION\"/" irissqlcli/__init__.py
git add irissqlcli/__init__.py
git commit -m 'auto bump version with release'
git push
homebrew:
needs: build
if: github.event_name == 'release'
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- name: set version
id: set-version
run: |
VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- uses: mislav/bump-homebrew-formula-action@v2
with:
formula-name: irissqlcli
formula-path: Formula/irissqlcli.rb
homebrew-tap: caretdev/homebrew-tap
base-branch: main
download-url: https://pypi.io/packages/source/i/irissqlcli/irissqlcli-${{ steps.set-version.outputs.version }}.tar.gz
commit-message: |
{{formulaName}} {{version}}
Created by https://github.com/mislav/bump-homebrew-formula-action
env:
COMMITTER_TOKEN: ${{ secrets.TOKEN }}