-
Notifications
You must be signed in to change notification settings - Fork 14
155 lines (148 loc) · 5.3 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
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
---
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.10"
- uses: pre-commit/[email protected]
test:
name: run tox tests
runs-on: ubuntu-latest
steps:
- name: Install krb5-config libvirt-dev # missing distro dependencies
run: sudo apt update && sudo apt-get install libkrb5-dev libvirt-dev
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Tox and any other packages
run: pip install tox
- name: Run Tox
run: tox -e py
release:
name: mrack semantic release 🐕
runs-on: ubuntu-latest
needs: [pre-commit, test]
if: github.repository == 'neoave/mrack'
outputs:
new_version: ${{ steps.set_version.outputs.new_version }}
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- 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==8.1.1
echo "NEW_VERSION="`semantic-release version --print` >> ${GITHUB_ENV}
- name: Update the mrack.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 mrack.spec
sed -i '/%changelog/r changelog_changes' mrack.spec
# write header of changelog to mrack.spec
sed -ri \
"s/\%changelog/\%changelog\\n\*\ $TODAY\ $RELEASE_ACTOR\ -\ $NEW_VERSION-1/" \
mrack.spec
- name: Add version to specfile
run: |
export SPEC_VERSION_REGEX="s/^Version:(\s+)(.*)/Version:\1$NEW_VERSION/"
echo $SPEC_VERSION_REGEX
sed -i -E $SPEC_VERSION_REGEX mrack.spec
- name: Add specfile to commit
run: git add mrack.spec
- name: Python Semantic Release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.TIBORIS_GH_TOKEN }}
- name: Set NEW_VERSION as output
id: set_version
run: echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
copr-build:
name: Copr 📦 build for mrack
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Trigger COPR build
run: curl -X POST ${{ secrets.COPR_WEBHOOK_URL }}
python-build:
name: Build 🐍 distribution 📦
runs-on: ubuntu-latest
needs: [release]
steps:
- uses: actions/checkout@v4
- name: Checkout latest release commit
run: |
git fetch
git checkout $(git rev-parse FETCH_HEAD)
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload v${{ needs.release.outputs.new_version }} dist/*
publish-to-pypi:
name: >-
Publish 🐍 distribution 📦 to PyPI
needs: [python-build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/mrack/
# IMPORTANT: mandatory for trusted publishing which is setup on pypi
permissions:
id-token: write
steps:
- name: Download all the dists from artifacts
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: list dist dir
run: ls -la dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1