Skip to content

Commit f740bbf

Browse files
Merge pull request #96 from easyscience/develop
Release: merge develop into master
2 parents da08c50 + 63f8817 commit f740bbf

File tree

103 files changed

+3191
-2720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3191
-2720
lines changed

.github/workflows/build-docs.yml

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1+
# This workflow builds and deploys documentation for the project.
2+
#
3+
# Steps overview:
4+
# Job 1: build-docs
5+
# - Builds documentation (including running Jupyter notebooks to generate output cells).
6+
# - Uploads the built site as a Pages artifact.
7+
# Job 2: deploy-dev
8+
# - Deploys the built site to GitHub Pages for development (pushes to develop/master).
9+
# Job 3: deploy-prod
10+
# - Deploys the built site to gh_pages branch for production (release tags starting with v*).
11+
# - This triggers deployment to a custom domain via webhook.
12+
#
13+
# The action summary page will contain links to the built artifact for downloading
14+
# and inspecting, as well as links to both the development and production versions of
15+
# the deployed documentation site.
16+
117
name: Build and deploy docs
218

319
on:
20+
# Trigger the workflow on pull request
21+
pull_request:
22+
# Selected branches
23+
branches: [master, develop]
424
# Trigger the workflow on push
525
push:
626
# Selected branches
7-
branches: [master, develop, docs, patch]
27+
branches: [master, develop]
828
# Runs on creating a new tag starting with 'v', e.g. 'v1.0.3'
9-
tags:
10-
- 'v*'
29+
tags: ['v*']
1130
# Allows you to run this workflow manually from the Actions tab
1231
workflow_dispatch:
1332

@@ -41,7 +60,7 @@ jobs:
4160

4261
steps:
4362
- name: Check-out repository
44-
uses: actions/checkout@v4
63+
uses: actions/checkout@v5
4564
with:
4665
fetch-depth: 0 # full history + tags. needed to get the latest release version
4766

@@ -92,6 +111,12 @@ jobs:
92111
- name: Convert tutorial scripts to notebooks
93112
run: pixi run notebook-prepare
94113

114+
# The following step is needed to avoid the following message during the build:
115+
# "Matplotlib is building the font cache; this may take a moment"
116+
- name: Pre-build site step
117+
run: pixi run python -c "import easydiffraction"
118+
119+
# Run the notebooks to generate the output cells using multiple cores
95120
- name: Run notebooks
96121
run: pixi run notebook-exec
97122

@@ -121,26 +146,15 @@ jobs:
121146
# Upload the static files from the site/ directory to be used in the next job
122147
# This artifact is named github-pages and is a single gzip archive containing a single tar file
123148
# The artifact is then used in the next job by actions/deploy-pages to deploy the static files to GitHub Pages
124-
# Unfortunately, the artifact is not available for download, so extra steps below are needed to do similar things
125-
- name: Upload built site as artifact for DEV deployment (all branches)
149+
# It can also be downloaded using the actions/download-artifact, as the current upload-pages-artifact
150+
# is a wrapper which triggers the actions/upload-artifact.
151+
- name: Upload built site as artifact
126152
uses: actions/upload-pages-artifact@v3
127153
with:
128154
path: site/
129155

130-
# Upload the static files from the site/ directory to be used in the next job
131-
# This artifact is only uploaded on tagged releases (tags starting with 'v', e.g., v1.0.3)
132-
# and is used to push content to gh_pages for custom domain deployment.
133-
- name: Upload built site as artifact for PROD deployment (tagged release)
134-
if: startsWith(github.ref, 'refs/tags/v')
135-
uses: actions/upload-artifact@v4
136-
with:
137-
name: artifact # name of the artifact (without the extension zip)
138-
path: site/
139-
if-no-files-found: 'error'
140-
compression-level: 0
141-
142-
# Job 2: Deploy the static files
143-
deploy-docs:
156+
# Job 2: Deploy the built static files to GitHub Pages (DEV deployment)
157+
deploy-dev:
144158
needs: build-docs # previous job 'build-docs' need to be finished first
145159

146160
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
@@ -152,38 +166,59 @@ jobs:
152166
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
153167
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
154168
concurrency:
155-
group: 'pages'
169+
group: 'pages-dev'
156170
cancel-in-progress: false
157171

158172
# Deploy to the github-pages environment
159173
environment:
160-
name: github-pages # Artifact name
174+
name: github-pages # Environment name
161175
url: ${{ steps.deployment.outputs.page_url }}
162176

163177
runs-on: ubuntu-latest
164178

179+
# Triggered on push to develop or master branch only
180+
if: ${{ github.ref_name == 'develop' || github.ref_name == 'master' }}
181+
165182
steps:
166183
# Deploy the static files created in the previous job to GitHub Pages
167184
# To allow the deployment of the static files to GitHub Pages, no
168185
# restrictions on the branch name need to be set for desired branches on
169186
# https://github.com/easyscience/diffraction-lib/settings/environments
170187
# Deployed pages are available at https://easyscience.github.io/diffraction-lib
171-
- name: DEV deployment (all branches)
188+
- name: DEV deployment
172189
uses: actions/deploy-pages@v4
173190

174-
- name: Show DEV deployment url (all branches)
191+
- name: Add DEV deployment url to summary
175192
run:
176193
echo "🔗 DEV deployment url [${{ env.DEV_DEPLOYMENT_URL }}](${{
177194
env.DEV_DEPLOYMENT_URL }})" >> $GITHUB_STEP_SUMMARY
178195

196+
# Job 3: Deploy the built static files to GitHub Pages (PROD deployment)
197+
deploy-prod:
198+
needs: deploy-dev # previous job 'deploy-dev' needs to be finished first
199+
200+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
201+
permissions:
202+
contents: read
203+
204+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
205+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
206+
concurrency:
207+
group: 'pages-prod'
208+
cancel-in-progress: false
209+
210+
runs-on: ubuntu-latest
211+
212+
# Triggered on tagged releases only (tags starting with 'v', e.g., v1.0.3)
213+
if: startsWith(github.ref, 'refs/tags/v')
214+
215+
steps:
179216
# Download built site as artifact from a previous job for gh_pages (tagged release)
180-
# This artifact is only downloaded on tagged releases (tags starting with 'v', e.g., v1.0.3)
181-
# and is used to push content to gh_pages for custom domain deployment.
182-
- name: Download built site from previous job (tagged release)
183-
if: startsWith(github.ref, 'refs/tags/v')
217+
# This artifact is used to push its content to gh_pages branch for custom domain deployment.
218+
- name: Download built site from previous job
184219
uses: actions/download-artifact@v4
185220
with: # name or path are taken from the upload step of the previous job
186-
name: artifact
221+
name: github-pages
187222
path: site/ # directory to extract downloaded zipped artifacts
188223

189224
# Push the site files created in the previous job to the gh_pages branch
@@ -196,16 +231,15 @@ jobs:
196231
# Then the gh_pages branch is used to deploy the site to the custom domain.
197232
# Deploying is done with a webhook added via:
198233
# https://github.com/easyscience/diffraction-lib/settings/hooks
199-
- name: PROD deployment to gh_pages for custom domain (tagged release)
200-
if: startsWith(github.ref, 'refs/tags/v')
234+
- name: PROD deployment to gh_pages for custom domain
201235
uses: s0/git-publish-subdir-action@develop
202236
env:
203237
GITHUB_TOKEN: ${{ secrets.GH_API_PERSONAL_ACCSESS_TOKEN }}
204238
REPO: self
205239
BRANCH: gh_pages
206240
FOLDER: site
207241

208-
- name: Show PROD deployment url (tagged release)
242+
- name: Show PROD deployment url
209243
if: startsWith(github.ref, 'refs/tags/v')
210244
run:
211245
echo "🔗 PROD deployment url [${{ env.PROD_DEPLOYMENT_URL }}](${{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow creates an automated release PR from `develop` into `master`.
2+
#
3+
# Usage:
4+
# - Triggered manually via workflow_dispatch.
5+
# - Creates a PR titled "Release: merge develop into master".
6+
# - Adds the label "[maintainer] release" so it is excluded from changelogs.
7+
# - The PR body makes clear that this is automation only (no review needed).
8+
9+
name: Create release PR
10+
11+
on:
12+
workflow_dispatch: # manual trigger only
13+
14+
jobs:
15+
create-pr:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5
19+
20+
- name: Create PR from develop to master
21+
uses: peter-evans/create-pull-request@v6
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
branch: develop
25+
base: master
26+
title: 'Release: merge develop into master'
27+
body: |
28+
This pull request is created automatically to trigger the release
29+
pipeline. It merges the accumulated changes from `develop` into
30+
`master`.
31+
32+
⚠️ Note: This PR is labeled **[maintainer] release** and is excluded
33+
from release notes and version bump logic.
34+
labels: '[maintainer] release'
35+
draft: false

.github/workflows/draft-release-notes.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
# Runs on pushes targeting the default branch (updates the real draft release)
88
push:
99
branches: [master]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
1012

1113
jobs:
1214
draft-release-notes:
@@ -17,9 +19,34 @@ jobs:
1719
runs-on: ubuntu-latest
1820

1921
steps:
20-
- name: Drafts the next release notes
21-
uses: enhantica/drafterino@v1
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 0 # full history with tags to get the version number by drafterino
26+
27+
- name: Set up pixi
28+
uses: prefix-dev/[email protected]
29+
with:
30+
environments: >-
31+
default
32+
activate-environment: default
33+
run-install: true
34+
frozen: true
35+
cache: false
36+
post-cleanup: false
37+
38+
- name: Convert tutorial scripts to notebooks
39+
run: pixi run notebook-prepare
40+
41+
- name: Clean up unnecessary script files
42+
run: rm -rf tutorials/*.py
2243

44+
- name: Zip the tutorials directory
45+
run: zip -9 -r tutorials.zip tutorials
46+
47+
- name: Drafts the next release notes
48+
id: draft
49+
uses: enhantica/drafterino@v2
2350
with:
2451
config: |
2552
title: 'easydiffraction $COMPUTED_VERSION'
@@ -43,3 +70,15 @@ jobs:
4370
4471
env:
4572
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: Create GitHub draft release
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
draft: true
78+
tag_name: ${{ steps.draft.outputs.tag_name }}
79+
name: ${{ steps.draft.outputs.release_name }}
80+
body: ${{ steps.draft.outputs.release_notes }}
81+
files: |
82+
tutorials.zip
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-pypi.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ name: Publish to PyPI
66
on:
77
# Runs on creating a new tag starting with 'v', e.g. 'v1.0.3'
88
push:
9-
tags:
10-
- 'v*'
9+
tags: ['v*']
1110
# Allows you to run this workflow manually from the Actions tab
1211
workflow_dispatch:
1312

@@ -17,7 +16,7 @@ jobs:
1716

1817
steps:
1918
- name: Check-out repository
20-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2120
with:
2221
fetch-depth: '0' # full history with tags to get the version number by versioningit
2322

.github/workflows/scan-security.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ name: Scan security (static analysis)
77
on:
88
# Trigger the workflow on pull request
99
pull_request:
10-
branches:
11-
- '**'
10+
branches: ['**']
1211
# Allows you to run this workflow manually from the Actions tab
1312
workflow_dispatch:
1413

@@ -20,7 +19,7 @@ jobs:
2019

2120
steps:
2221
- name: Checkout repository
23-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2423
with:
2524
# We must fetch at least the immediate parents so that if this is
2625
# a pull request then we can checkout the head.

0 commit comments

Comments
 (0)