Skip to content

Commit 4a22040

Browse files
committed
CI: add smarter release management
1 parent b3515df commit 4a22040

File tree

3 files changed

+187
-8
lines changed

3 files changed

+187
-8
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
workflow_dispatch: {}
8+
push: {}
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build_deps:
14+
permissions:
15+
contents: write
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
# os: [ubuntu-latest, windows-latest, macOS-latest]
20+
os: [windows-latest]
21+
platform: [x86, x64]
22+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
23+
python-platform: [x86, x64]
24+
# exclude:
25+
# - platform: x86
26+
# python-platform: x64
27+
# - os: ubuntu-latest
28+
# python-platform: x86
29+
# - os: ubuntu-latest
30+
# platform: x86
31+
# - os: macOS-latest
32+
# python-platform: x86
33+
# - os: macOS-latest
34+
# platform: x86
35+
# - platform: x64
36+
# python-platform: x86
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Set up Python ${{ matrix.python-version }}
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
architecture: ${{ matrix.python-platform }}
44+
- name: Enable Developer Command Prompt
45+
uses: ilammy/[email protected]
46+
with:
47+
arch: ${{ matrix.python-platform }}
48+
if: matrix.os == 'windows-latest'
49+
- name: Install dependencies
50+
shell: bash
51+
run: |
52+
python -m pip install --upgrade pip
53+
python -m pip install --upgrade wheel setuptools Cython
54+
pip install flake8 pytest
55+
pip install -r requirements.txt
56+
- name: Lint with flake8
57+
shell: bash
58+
run: |
59+
# stop the build if there are Python syntax errors or undefined names
60+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude examples
61+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
62+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude examples
63+
64+
- name: Run tests
65+
shell: bash
66+
run: |
67+
python -m pip install pytest
68+
python -m pytest
69+
70+
- name: Build wheel dependencies
71+
shell: bash
72+
run: |
73+
python -m pip wheel . -w dist
74+
75+
- name: Archive packages
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: dclimplode-py${{ matrix.python-version }}-${{ matrix.python-platform }}-${{ matrix.os }}-${{ matrix.platform }}
79+
path: |
80+
dist/dclimplode-*
81+
82+
- name: Ensure release exists
83+
if: github.ref_type == 'tag'
84+
shell: bash
85+
env:
86+
GH_TOKEN: ${{ github.token }}
87+
run: |
88+
# Set continue on error to true
89+
set +e
90+
if [[ "$(gh --repo sourcehold/sourcehold-maps release view $RELEASE_TAG 2>&1)" == "release not found" ]]; then
91+
set -e
92+
gh --repo sourcehold/sourcehold-maps release create ${{ github.ref_name }} --latest
93+
fi
94+
- name: Upload dclimplode wheel to release
95+
if: github.ref_type == 'tag'
96+
shell: bash
97+
env:
98+
GH_TOKEN: ${{ github.token }}
99+
run: |
100+
gh --repo sourcehold/sourcehold-maps release upload ${{ github.ref_name }} dist/dclimplode-*

.github/workflows/python-package.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
name: Python package
55

66
on:
7+
workflow_dispatch: {}
78
push: {}
89
pull_request:
910
branches: [ master ]
@@ -34,7 +35,7 @@ jobs:
3435
# - platform: x64
3536
# python-platform: x86
3637
steps:
37-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v4
3839
- name: Set up Python ${{ matrix.python-version }}
3940
uses: actions/setup-python@v5
4041
with:
@@ -81,15 +82,27 @@ jobs:
8182
with:
8283
name: sourcehold-py${{ matrix.python-version }}-${{ matrix.python-platform }}-${{ matrix.os }}-${{ matrix.platform }}
8384
path: |
84-
dist/*
85+
dist/sourcehold*
8586
86-
- name: Release
87-
uses: softprops/action-gh-release@v2
87+
- name: Ensure release exists
8888
if: github.ref_type == 'tag'
89-
with:
90-
name: ${{github.ref_name}}
91-
tag_name: ${{github.ref_name}}
92-
files: dist/*
89+
shell: bash
90+
env:
91+
GH_TOKEN: ${{ github.token }}
92+
run: |
93+
# Set continue on error to true
94+
set +e
95+
if [[ "$(gh --repo sourcehold/sourcehold-maps release view $RELEASE_TAG 2>&1)" == "release not found" ]]; then
96+
set -e
97+
gh --repo sourcehold/sourcehold-maps release create ${{ github.ref_name }} --latest
98+
fi
99+
- name: Upload wheel to release
100+
if: github.ref_type == 'tag'
101+
shell: bash
102+
env:
103+
GH_TOKEN: ${{ github.token }}
104+
run: |
105+
gh --repo sourcehold/sourcehold-maps release upload ${{ github.ref_name }} dist/sourcehold*.whl
93106
94107
test_package:
95108
needs: build
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# pyinstaller --console --one-file .\sourcehold\__main__.py
2+
3+
4+
name: Python package
5+
6+
on:
7+
workflow_dispatch: {}
8+
push: {}
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build_deps:
14+
permissions:
15+
contents: write
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
# os: [ubuntu-latest, windows-latest, macOS-latest]
20+
os: [windows-latest, ubuntu-latest, macOS-latest]
21+
platform: [x86]
22+
python-version: ['3.13']
23+
python-platform: [x86]
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
architecture: ${{ matrix.python-platform }}
31+
- name: Enable Developer Command Prompt
32+
uses: ilammy/[email protected]
33+
with:
34+
arch: ${{ matrix.python-platform }}
35+
if: matrix.os == 'windows-latest'
36+
- name: Install dependencies
37+
shell: bash
38+
run: |
39+
python -m pip install --upgrade pip
40+
python -m pip install --upgrade wheel setuptools Cython
41+
pip install flake8 pytest
42+
pip install -r requirements.txt
43+
python -m pip install pyinstaller
44+
- name: Run pyinstaller
45+
shell: bash
46+
run: |
47+
pyinstaller --console --onefile ./sourcehold/__main__.py --name sourcehold
48+
- name: Ensure release exists
49+
if: github.ref_type == 'tag'
50+
shell: bash
51+
env:
52+
GH_TOKEN: ${{ github.token }}
53+
run: |
54+
# Set continue on error to true
55+
set +e
56+
if [[ "$(gh --repo sourcehold/sourcehold-maps release view $RELEASE_TAG 2>&1)" == "release not found" ]]; then
57+
set -e
58+
gh --repo sourcehold/sourcehold-maps release create ${{ github.ref_name }} --latest
59+
fi
60+
- name: Upload pyinstaller to release
61+
if: github.ref_type == 'tag'
62+
shell: bash
63+
env:
64+
GH_TOKEN: ${{ github.token }}
65+
run: |
66+
gh --repo sourcehold/sourcehold-maps release upload ${{ github.ref_name }} dist/sourcehold*

0 commit comments

Comments
 (0)