|
| 1 | +name: Pre-release CD |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - "main" |
| 7 | + |
| 8 | +defaults: |
| 9 | + run: |
| 10 | + shell: bash -l {0} |
| 11 | + |
| 12 | +concurrency: |
| 13 | + # Use github.run_id on main branch |
| 14 | + # Use github.event.pull_request.number on pull requests, so it's unique per pull request |
| 15 | + # Use github.ref on other branches, so it's unique per branch |
| 16 | + group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + pre-release-version: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + if: startsWith(github.event.pull_request.title, 'Release v') |
| 23 | + outputs: |
| 24 | + version: ${{ steps.get-version.outputs.version }} |
| 25 | + steps: |
| 26 | + - id: get-version |
| 27 | + run: | |
| 28 | + fullname="${{github.event.pull_request.title}}" |
| 29 | + echo "version=${fullname#"Release "}" >> $GITHUB_OUTPUT |
| 30 | +
|
| 31 | + pip-test: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + if: startsWith(github.event.pull_request.title, 'Release v') |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + - uses: mamba-org/setup-micromamba@v1 |
| 37 | + with: |
| 38 | + micromamba-version: '1.5.10-0' |
| 39 | + environment-name: pipbuild |
| 40 | + create-args: >- |
| 41 | + python=3.11 |
| 42 | + pip |
| 43 | + python-build |
| 44 | + post-cleanup: all |
| 45 | + cache-environment: true |
| 46 | + - name: Build package |
| 47 | + run: python -m build |
| 48 | + - name: Test package install |
| 49 | + run: | |
| 50 | + pip install dist/calliope-*.tar.gz |
| 51 | + calliope --help |
| 52 | +
|
| 53 | + pre-release: |
| 54 | + needs: [pre-release-version, pip-test] |
| 55 | + if: needs.pip-test.result == 'success' && startsWith(github.event.pull_request.title, 'Release v') |
| 56 | + uses: arup-group/actions-city-modelling-lab/.github/workflows/pip-build.yml@main |
| 57 | + secrets: |
| 58 | + TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 59 | + with: |
| 60 | + package_name: calliope |
| 61 | + version: ${{needs.pre-release-version.outputs.version}} |
| 62 | + pip_args: '' |
0 commit comments