-
Notifications
You must be signed in to change notification settings - Fork 0
Add conda and PyPI builds #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: CD | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
PY_VERSION: 3.12 | ||
|
||
jobs: | ||
pypi-build: | ||
name: Build package for PyPI | ||
if: github.repository == 'ACCESS-NRI/access-parsers' # exclude forks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PY_VERSION }} | ||
|
||
- run: | | ||
python3 -m pip install --upgrade build && python3 -m build | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: release | ||
path: dist | ||
|
||
pypi-publish: | ||
# Split build and publish to restrict trusted publishing to just this workflow | ||
needs: ['pypi-build'] | ||
name: Publish to PyPI.org | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# IMPORTANT: this permission is mandatory for trusted publishing | ||
id-token: write | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: release | ||
path: dist | ||
|
||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 | ||
|
||
conda: | ||
name: Build with conda and upload | ||
if: github.repository == 'ACCESS-NRI/access-parsers' # exclude forks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup conda environment | ||
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ env.PY_VERSION }} | ||
environment-file: conda/environment.yml | ||
auto-update-conda: false | ||
auto-activate-base: false | ||
show-channel-urls: true | ||
|
||
- name: Build and upload conda package | ||
uses: ACCESS-NRI/[email protected] | ||
with: | ||
meta_yaml_dir: conda | ||
user: ${{ vars.ANACONDA_USER }} | ||
label: main | ||
token: ${{ secrets.ANACONDA_TOKEN }} | ||
Comment on lines
+69
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to add these to the repo if you haven't already. Happy to help with this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming the token is stored somewhere. bitwarden maybe? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually have been generating a separate token for each project. There was a discussion in the Python Standards Group a while back about whether this is a good idea and I think we resolved to continue doing this. There are some instructions here for how to generate one: https://github.com/ACCESS-NRI/dev-docs/wiki/Continuous-integration-and-Deployment#publishing-a-python-package-to-conda They require that you are a member of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dougiesquire can you add me in too? (I reckon I asked this question before) |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: access-parsers | ||
name: CI | ||
|
||
on: | ||
push: | ||
|
@@ -12,6 +12,9 @@ on: | |
permissions: | ||
contents: read | ||
|
||
env: | ||
PY_VERSION_BUILD: 3.12 | ||
|
||
jobs: | ||
formatting: | ||
runs-on: ubuntu-latest | ||
|
@@ -23,6 +26,43 @@ jobs: | |
options: "--check --verbose --diff" | ||
src: "./src ./tests" | ||
|
||
pypa-build: | ||
name: PyPA build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PY_VERSION_BUILD }} | ||
cache: 'pip' # caching pip dependencies | ||
|
||
- run: | | ||
python3 -m pip install --upgrade build && python3 -m build | ||
|
||
conda-build: | ||
name: Conda Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup conda environment | ||
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ env.PY_VERSION_BUILD }} | ||
environment-file: conda/environment.yml | ||
auto-update-conda: false | ||
auto-activate-base: false | ||
show-channel-urls: true | ||
|
||
- name: Build conda package | ||
uses: ACCESS-NRI/[email protected] | ||
with: | ||
meta_yaml_dir: conda | ||
label: main | ||
upload: false | ||
|
||
build: | ||
needs: formatting | ||
runs-on: ubuntu-latest | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
channels: | ||
- conda-forge | ||
- accessnri | ||
- default | ||
|
||
dependencies: | ||
- anaconda-client | ||
- conda-build | ||
- conda-verify | ||
- setuptools_scm |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %} | ||
{% set version = data.get('version') %} | ||
{% set pyproj = load_file_data('../pyproject.toml', from_recipe_dir=True) %} | ||
{% set project = pyproj.get('project') %} | ||
|
||
package: | ||
name: access-parsers | ||
version: "{{ version }}" | ||
|
||
build: | ||
noarch: python | ||
number: 0 | ||
script: "{{ PYTHON }} -m pip install . -vv" | ||
entry_points: | ||
{% for name, script in project.get('scripts', {}).items() %} | ||
- {{ name }} = {{ script }} | ||
{% endfor %} | ||
|
||
source: | ||
path: ../ | ||
|
||
requirements: | ||
host: | ||
- python | ||
- pip | ||
- setuptools >=61.0.0 | ||
- setuptools_scm | ||
run: | ||
- python >=3.10 | ||
{% for dep in project.get('dependencies', []) %} | ||
- {{ dep }} | ||
{% endfor %} | ||
|
||
test: | ||
imports: | ||
- access.parsers | ||
|
||
about: | ||
home: https://github.com/ACCESS-NRI/access-parsers/ | ||
license: Apache Software | ||
license_family: APACHE | ||
summary: "Various functions to read and write configuration files for the models developed at ACCESS-NRI." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This file is only needed for the automatic versioning in the conda recipe | ||
from setuptools import setup | ||
import setuptools_scm | ||
|
||
setup(version=setuptools_scm.get_version()) |
Uh oh!
There was an error while loading. Please reload this page.