|
| 1 | +name: CD |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' |
| 6 | + |
| 7 | +env: |
| 8 | + PY_VERSION: 3.12 |
| 9 | + |
| 10 | +jobs: |
| 11 | + pypi-build: |
| 12 | + name: Build package for PyPI |
| 13 | + if: github.repository == 'ACCESS-NRI/access-parsers' # exclude forks |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: ${{ env.PY_VERSION }} |
| 21 | + |
| 22 | + - run: | |
| 23 | + python3 -m pip install --upgrade build && python3 -m build |
| 24 | +
|
| 25 | + - uses: actions/upload-artifact@v4 |
| 26 | + with: |
| 27 | + name: release |
| 28 | + path: dist |
| 29 | + |
| 30 | + pypi-publish: |
| 31 | + # Split build and publish to restrict trusted publishing to just this workflow |
| 32 | + needs: ['pypi-build'] |
| 33 | + name: Publish to PyPI.org |
| 34 | + runs-on: ubuntu-latest |
| 35 | + permissions: |
| 36 | + # IMPORTANT: this permission is mandatory for trusted publishing |
| 37 | + id-token: write |
| 38 | + steps: |
| 39 | + - uses: actions/download-artifact@v4 |
| 40 | + with: |
| 41 | + name: release |
| 42 | + path: dist |
| 43 | + |
| 44 | + - name: Publish package distributions to PyPI |
| 45 | + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 |
| 46 | + |
| 47 | + conda: |
| 48 | + name: Build with conda and upload |
| 49 | + if: github.repository == 'ACCESS-NRI/access-parsers' # exclude forks |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Checkout source |
| 53 | + uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Setup conda environment |
| 56 | + uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 |
| 57 | + with: |
| 58 | + miniconda-version: "latest" |
| 59 | + python-version: ${{ env.PY_VERSION }} |
| 60 | + environment-file: conda/environment.yml |
| 61 | + auto-update-conda: false |
| 62 | + auto-activate-base: false |
| 63 | + show-channel-urls: true |
| 64 | + |
| 65 | + - name: Build and upload conda package |
| 66 | + uses: ACCESS-NRI/[email protected] |
| 67 | + with: |
| 68 | + meta_yaml_dir: conda |
| 69 | + user: ${{ vars.ANACONDA_USER }} |
| 70 | + label: main |
| 71 | + token: ${{ secrets.ANACONDA_TOKEN }} |
| 72 | + |
0 commit comments