1818 types :
1919 - published
2020
21+ permissions : {}
22+
2123# Use bash by default in all jobs
2224defaults :
2325 run :
2426 # The -l {0} is necessary for conda environments to be activated
2527 # But this breaks on MacOS if using actions/setup-python:
2628 # https://github.com/actions/setup-python/issues/132
27- shell : bash -l {0}
29+ # -e makes sure builds fail if any command fails
30+ shell : bash -e -o pipefail -l {0}
2831
2932jobs :
3033 # ############################################################################
3336 runs-on : ubuntu-latest
3437 env :
3538 REQUIREMENTS : env/requirements-build.txt env/requirements-docs.txt
36- PYTHON : " 3.11"
39+ PYTHON : " 3.12"
40+ ENSAIO_DATA_FROM_GITHUB : true
3741
3842 steps :
3943
5862 uses : conda-incubator/setup-miniconda@v3
5963 with :
6064 python-version : ${{ env.PYTHON }}
61- miniforge-variant : Mambaforge
62- use-mamba : true
63- channels : conda-forge,defaults
64- # Allow mamba to use other than tar.bz2
65+ miniforge-version : latest
66+ channels : conda-forge
67+ # Allow conda to use other than tar.bz2
6568 # (otherwise it cannot find latest versions that
6669 # don't use tar-bz2 files, see
6770 # https://github.com/conda-incubator/setup-miniconda/issues/267)
7073 - name : Collect requirements
7174 run : |
7275 echo "Install Dependente to capture dependencies:"
73- mamba install dependente==0.3.0 -c conda-forge
76+ conda install dependente==0.3.0 -c conda-forge
7477 echo ""
7578 echo "Capturing run-time dependencies:"
7679 dependente --source install > requirements-full.txt
@@ -84,17 +87,25 @@ jobs:
8487 echo "Collected dependencies:"
8588 cat requirements-full.txt
8689
90+ - name : Rename conda-forge packages
91+ run : |
92+ echo "Rename conda-forge packages in requirements-full.txt"
93+ # Replace "build" for "python-build"
94+ sed -s --in-place 's/^build$/python-build/' requirements-full.txt
95+ echo "Renamed dependencies:"
96+ cat requirements-full.txt
97+
8798 - name : Setup caching for conda packages
8899 uses : actions/cache@v4
89100 with :
90101 path : ~/conda_pkgs_dir
91102 key : conda-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('requirements-full.txt') }}
92103
93104 - name : Install requirements
94- run : mamba install --quiet --file requirements-full.txt python=$PYTHON
105+ run : conda install --quiet --file requirements-full.txt python=$PYTHON
95106
96107 - name : List installed packages
97- run : mamba list
108+ run : conda list
98109
99110 - name : Build source and wheel distributions
100111 run : |
@@ -133,11 +144,17 @@ jobs:
133144 publish :
134145 runs-on : ubuntu-latest
135146 needs : build
147+ permissions :
148+ contents : write
136149 if : github.event_name == 'release' || github.event_name == 'push'
137150
138151 steps :
139152 - name : Checkout
140153 uses : actions/checkout@v4
154+ with :
155+ # The GitHub token is preserved by default but this job doesn't need
156+ # to be able to push to GitHub.
157+ persist-credentials : false
141158
142159 # Fetch the built docs from the "build" job
143160 - name : Download HTML documentation artifact
@@ -154,33 +171,36 @@ jobs:
154171 path : deploy
155172 # Download the entire history
156173 fetch-depth : 0
174+ # We need to explicitly preserve the credentials for the GitHub token
175+ # on this branch so we can push to it.
176+ persist-credentials : true
157177
158178 - name : Push the built HTML to gh-pages
159179 run : |
160180 # Detect if this is a release or from the main branch
161181 if [[ "${{ github.event_name }}" == "release" ]]; then
162- # Get the tag name without the "refs/tags/" part
163- version="${GITHUB_REF#refs/*/}"
182+ # Get the tag name without the "refs/tags/" part
183+ version="${GITHUB_REF#refs/*/}"
164184 else
165- version=dev
185+ version=dev
166186 fi
167187 echo "Deploying version: $version"
168188 # Make the new commit message. Needs to happen before cd into deploy
169189 # to get the right commit hash.
170190 message="Deploy $version from $(git rev-parse --short HEAD)"
171- cd deploy
191+ cd deploy || exit 1
172192 # Need to have this file so that Github doesn't try to run Jekyll
173193 touch .nojekyll
174194 # Delete all the files and replace with our new set
175195 echo -e "\nRemoving old files from previous builds of ${version}:"
176- rm -rvf ${version}
196+ rm -rvf " ${version}"
177197 echo -e "\nCopying HTML files to ${version}:"
178- cp -Rvf ../doc/_build/html/ ${version}/
198+ cp -Rvf ../doc/_build/html/ " ${version}/"
179199 # If this is a new release, update the link from /latest to it
180200 if [[ "${version}" != "dev" ]]; then
181- echo -e "\nSetup link from ${version} to 'latest'."
182- rm -f latest
183- ln -sf ${version} latest
201+ echo -e "\nSetup link from ${version} to 'latest'."
202+ rm -f latest
203+ ln -sf " ${version}" latest
184204 fi
185205 # Stage the commit
186206 git add -A .
@@ -192,15 +212,15 @@ jobs:
192212 # If this is a dev build and the last commit was from a dev build
193213 # (detect if "dev" was in the previous commit message), reuse the
194214 # same commit
195- if [[ "${version}" == "dev" && ` git log -1 --format='%s'` == *"dev"* ]]; then
196- echo -e "\nAmending last commit:"
197- git commit --amend --reset-author -m "$message"
215+ if [[ "${version}" == "dev" && $( git log -1 --format='%s') == *"dev"* ]]; then
216+ echo -e "\nAmending last commit:"
217+ git commit --amend --reset-author -m "$message"
198218 else
199- echo -e "\nMaking a new commit:"
200- git commit -m "$message"
219+ echo -e "\nMaking a new commit:"
220+ git commit -m "$message"
201221 fi
202222 # Make the push quiet just in case there is anything that could leak
203223 # sensitive information.
204224 echo -e "\nPushing changes to gh-pages."
205- git push -fq origin gh-pages 2>&1 > /dev/null
225+ { git push -fq origin gh-pages > /dev/null; } 2>&1
206226 echo -e "\nFinished uploading generated files."
0 commit comments