-
Notifications
You must be signed in to change notification settings - Fork 15
116 lines (100 loc) · 3.47 KB
/
Copy path_build.yaml
File metadata and controls
116 lines (100 loc) · 3.47 KB
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
# -*- mode: yaml; coding: utf-8 -*-
#
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
# All rights reserved.
# https://github.com/btschwertfeger
#
# Template workflow to build the project for a specific os
# and Python version.
#
name: Build
on:
workflow_call:
inputs:
os:
type: string
required: true
python-version:
type: string
required: true
permissions: read-all
jobs:
Build:
runs-on: ${{ inputs.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com
files.pythonhosted.org:443
github.com:443
pypi.org:443
release-assets.githubusercontent.com:443
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0 # IMPORTANT: otherwise the current tag does not get fetched and the build version gets worse
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ inputs.python-version }}
- name: Install dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install --user build
- name: Install hdf5 and netcdf (macOS)
if: runner.os == 'macOS'
run: brew install hdf5 netcdf
- name: Check git status (not Windows)
if: runner.os != 'Windows'
run: |
if [[ -z "$(git status --porcelain)" ]]; then
echo "No changes found."
else
echo "Changes detected. Please commit or discard changes before publishing."
git status --porcelain
exit 1
fi
- name: Check git status (Windows)
if: runner.os == 'Windows'
run: |
if (-not (git status --porcelain)) {
Write-Output "No changes found."
} else {
Write-Output "Changes detected. Please commit or discard changes before publishing."
git status --porcelain
exit 1
}
- name: Build Linux
if: runner.os == 'linux'
run: python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
# upload artifacts with the oldest supported version
if: runner.os == 'linux' && inputs.python-version == '3.9'
with:
name: python-package-distributions
path: dist/
- name: Build macOS
if: runner.os == 'macOS'
run: python -m build
- name: Build Windows
if: runner.os == 'Windows'
# put it here to avoid more filtering
run: python -m build -o .
- name: Install the package on Linux or MacOS
if: runner.os != 'Windows'
run: python -m pip install --user dist/python_cmethods*.whl
- name: Install the package on Windows
if: runner.os == 'Windows'
run: |
try {
$WHEEL = Get-ChildItem -Path . -Filter "python_cmethods*.whl" -ErrorAction Stop
python -m pip install --user $WHEEL
} catch {
Write-Error "Error: .whl file not found in the current directory."
exit 1
}