-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (145 loc) · 4.65 KB
/
release.yml
File metadata and controls
170 lines (145 loc) · 4.65 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# EnSim Release Pipeline
# Automatically creates releases when version tags are pushed
#
# Triggers:
# - Push of version tags (v*.*.*)
#
# Actions:
# - Build packages for all platforms
# - Create GitHub release with changelog
# - Publish to PyPI (when configured)
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
type: string
permissions:
contents: write
env:
PYTHON_VERSION: "3.11"
jobs:
# ============================================================================
# Build Job - Create distribution packages
# ============================================================================
build:
name: Build Packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build dependencies
run: |
pip install build wheel
- name: Build sdist and wheel
run: |
python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: dist/
# ============================================================================
# Release Job - Create GitHub release
# ============================================================================
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: packages
path: dist/
- name: Extract changelog for this version
id: changelog
run: |
VERSION=${GITHUB_REF#refs/tags/v}
if [ -z "$VERSION" ]; then
VERSION=${{ github.event.inputs.version }}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Extract changelog section
CHANGELOG=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$ d')
if [ -z "$CHANGELOG" ]; then
CHANGELOG="Release version $VERSION"
fi
# Write to file for multiline support
echo "$CHANGELOG" > release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: EnSim v${{ steps.changelog.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
files: |
dist/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================================================
# Publish Job - Publish to PyPI
# ============================================================================
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build, release]
if: ${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }}
environment:
name: pypi
url: https://pypi.org/project/ensim/
permissions:
id-token: write
contents: read
steps:
- uses: actions/download-artifact@v4
with:
name: packages
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
# ============================================================================
# Documentation Job - Build and publish docs
# ============================================================================
docs:
name: Update Documentation
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install documentation tools
run: |
pip install mkdocs mkdocs-material mkdocstrings[python]
- name: Build documentation
run: |
mkdocs build
continue-on-error: true
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
continue-on-error: true