-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (82 loc) · 3.12 KB
/
test-and-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
---
name: Test & Release
on: workflow_dispatch
jobs:
pre-commit:
name: run pre-commit hook
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: pre-commit/[email protected]
test:
name: run tox tests
runs-on: ubuntu-latest
steps:
- name: Install distro deps
run: sudo apt update
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Tox and any other packages
run: pip install tox
- name: Run Tox
run: tox -e py
release:
name: semantic release
runs-on: ubuntu-latest
needs: [pre-commit, test]
if: github.repository == 'neoave/te'
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Display Python version
run: python --version
- name: Set up changelog date to use later
run: echo "TODAY=`date "+%a %b %d %Y"`" >> ${GITHUB_ENV}
- name: Set RELEASE_ACTOR
env:
RELEASE_ACTOR_TIBORIS: ${{ secrets.RELEASE_ACTOR_TIBORIS }}
RELEASE_ACTOR_DAV_PASCUAL: ${{ secrets.RELEASE_ACTOR_DAV_PASCUAL }}
RELEASE_ACTOR_PVOBORNI: ${{ secrets.RELEASE_ACTOR_PVOBORNI }}
RELEASE_ACTOR_KALEEMSIDDIQU: ${{ secrets.RELEASE_ACTOR_KALEEMSIDDIQU }}
run: |
RELEASE_ACTOR=RELEASE_ACTOR_$(echo ${GITHUB_ACTOR^^} | tr - _)
echo "RELEASE_ACTOR=${!RELEASE_ACTOR}" >> ${GITHUB_ENV}
- uses: actions/checkout@v3
with:
persist-credentials: false # do not set the actions user to git config
fetch-depth: 0
- name: Get the new version using python-semantic-release
run: |
pip3 install python-semantic-release==7.33.1
echo "NEW_VERSION="`semantic-release print-version --noop` >> ${GITHUB_ENV}
- name: Update the te.spec changelog with initiator and basic message
run: |
# get the history of commits and generate changelog from it
git log --pretty=format:"- %h %s (%cn)" $(git describe --tags --abbrev=0)..HEAD > changelog_changes
# add newline after generated changelog for changelog sections to be visually separated
echo -e "\n" >> changelog_changes
echo "============NEW CHANGELOG================="
cat changelog_changes
echo "=========================================="
# write changelog to te.spec
sed -i '/%changelog/r changelog_changes' te.spec
# write header of changelog to te.spec
sed -ri \
"s/\%changelog/\%changelog\\n\*\ $TODAY\ $RELEASE_ACTOR\ -\ $NEW_VERSION-1/" \
te.spec
- name: Add specfile to commit
run: git add te.spec
- name: Python Semantic Release
uses: relekang/[email protected]
with:
github_token: ${{ secrets.TIBORIS_GH_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
- name: Trigger COPR build
run: curl -X POST ${{ secrets.COPR_WEBHOOK_URL }}