-
Notifications
You must be signed in to change notification settings - Fork 263
144 lines (128 loc) · 4.71 KB
/
deploy.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
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Deploy
on:
push:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
release-check:
runs-on: ubuntu-22.04
continue-on-error: ${{ startsWith(github.event.ref,'refs/heads/') }}
steps:
- uses: actions/checkout@v4
- name: fetch all tags # need annotated tags for release checklist
run: |
git fetch --force --tags --depth=1
- name: For a dry run, don't verify tags and documentation
if: ${{ ! startsWith(github.event.ref, 'refs/tags/') }}
run: |
echo "EXTRA_CHECKLIST_ARGS=--no-verify-tags --no-verify-docs-next-version" >> $GITHUB_ENV
- name: Run release checklist
run: |
admin/release_checklist.sh $EXTRA_CHECKLIST_ARGS 7.2+main
deploy:
runs-on: ubuntu-22.04
needs: release-check
permissions:
contents: write # Needed for pushing the tag
env:
FORCE_COLOR: "1"
PYTHON_VERSION: "3.8"
CC: "gcc-11"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('noxfile.py', 'doc/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install build commands and GCC
run: |
sudo apt update
sudo apt-get install -y \
make \
ninja-build \
$CC \
$(echo $CC | sed -e 's/gcc/g\+\+/')
sudo apt-get clean
- name: Install libxml2
run: |
sudo apt-get install -y libxml2-utils
sudo apt-get clean
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install nox requests
- name: Lint files
run: |
nox --non-interactive --session lint
- name: Test with pytest
run: |
nox --non-interactive --session tests
- name: Generate documentation
run: |
nox --non-interactive --session doc
# Check if files are modified (outdated screenshots)
Status=$(git status --porcelain | grep -F '.jpeg' || exit 0)
if [ -n "$Status" ] ; then
echo "Following files are modified:"
echo "$Status"
echo "Please regenerate the screenshots!"
exit 1
fi
exit 0
- name: Test bundle of app
run: |
nox --non-interactive --session bundle_app
- name: Build wheel
run: |
nox --non-interactive --session build_wheel
- name: Check wheel
run: |
nox --non-interactive --session check_wheel
- name: Upload distribution
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/**
- name: Apply new tag if version is bumped
if: ${{ success() && (github.event.ref == 'refs/heads/main') }}
run: |
set -e
# need to prevent creation of an existing tag
git fetch --force --tags --depth=1
# Set git user info
git config --global user.email "noreply@gcovr.com"
git config --global user.name "gcovr authors"
# Get the version
Version="$(sed -n 's/__version__.*"\(.*\)"/\1/ p' gcovr/version.py)"
# Try to create the tag and print the output. It's only pushed if it's a real release
git tag -a "$Version" -m "$Version ($(date -I))"
git tag --list -n "$Version"
# Check if it is a new release
VersionPostfix="$(echo "$Version" | sed -n 's/^[0-9]*\.[0-9]*// p')"
if [ -z "$VersionPostfix" ]; then
echo "New version bumped"
git push origin "refs/tags/$Version"
echo "TAG_PUSHED=true" >> $GITHUB_ENV
else
echo "Skip pushing tag for development build"
echo "TAG_PUSHED=false" >> $GITHUB_ENV
fi
- name: Publish
if: ${{ success() && (github.event.ref == 'refs/heads/main') && (env.TAG_PUSHED == 'true') }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m nox --session upload_wheel