|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + release: |
| 6 | + types: [ released ] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + freeze: |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + runs-on: |
| 18 | + - ubuntu-latest |
| 19 | + - macos-latest |
| 20 | + python-version: |
| 21 | + - "3.11" |
| 22 | + - "3.12" |
| 23 | + - "3.13" |
| 24 | + fail-fast: false |
| 25 | + runs-on: ${{ matrix.runs-on }} |
| 26 | + name: build frozen environment for Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} |
| 27 | + defaults: |
| 28 | + run: |
| 29 | + shell: bash -leo pipefail {0} |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 32 | + with: |
| 33 | + fetch-tags: true |
| 34 | + persist-credentials: false |
| 35 | + - uses: mamba-org/setup-micromamba@d7c9bd84e824b79d2af72a2d4196c7f4300d3476 # v3.0.0 |
| 36 | + with: |
| 37 | + environment-name: mirage-${{ runner.runs-on }}-py${{ matrix.python-version }} |
| 38 | + create-args: >- |
| 39 | + python=${{ matrix.python-version }} |
| 40 | + init-shell: bash |
| 41 | + generate-run-shell: false |
| 42 | + post-cleanup: none |
| 43 | + - run: pip install . |
| 44 | + - run: pip list |
| 45 | + - id: version |
| 46 | + name: retrieve package version |
| 47 | + run: echo version=$(python -c "import mirage; print(mirage.__version__)") >> $GITHUB_OUTPUT |
| 48 | + - id: filename |
| 49 | + run: echo "filename=mirage_${{ steps.version.outputs.version }}_conda_${{ runner.os }}_${{ runner.arch }}_py${{ matrix.python-version }}.yml" >> $GITHUB_OUTPUT |
| 50 | + - run: micromamba env export --no-build | grep -v "name:" | grep -v "prefix:" > ${{ steps.filename.outputs.filename }} |
| 51 | + - run: cat ${{ steps.filename.outputs.filename }} |
| 52 | + - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 53 | + with: |
| 54 | + name: ${{ steps.filename.outputs.filename }} |
| 55 | + path: ${{ steps.filename.outputs.filename }} |
| 56 | + - if: (github.event_name == 'release' && github.event.action == 'released') |
| 57 | + uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2.11.5 |
| 58 | + with: |
| 59 | + file: ${{ steps.filename.outputs.filename }} |
| 60 | + build: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 64 | + with: |
| 65 | + fetch-tags: true |
| 66 | + persist-credentials: false |
| 67 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 68 | + with: |
| 69 | + python-version: "3" |
| 70 | + - run: pip install build |
| 71 | + - run: python -m build --sdist --wheel |
| 72 | + - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 73 | + with: |
| 74 | + name: dist |
| 75 | + path: ./dist/ |
| 76 | + publish: |
| 77 | + if: (github.event_name == 'release') && (github.event.action == 'released') |
| 78 | + needs: [ build ] |
| 79 | + runs-on: ubuntu-latest |
| 80 | + permissions: |
| 81 | + id-token: write |
| 82 | + attestations: write |
| 83 | + # Requires environment protection rules in GitHub Settings: |
| 84 | + # Settings > Environments > pypi > Add required reviewers |
| 85 | + environment: |
| 86 | + name: pypi |
| 87 | + url: https://pypi.org/p/{{ cookiecutter.package_name }} |
| 88 | + steps: |
| 89 | + - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 90 | + with: |
| 91 | + pattern: dist* |
| 92 | + path: dist/ |
| 93 | + merge-multiple: true |
| 94 | + - uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0 |
| 95 | + with: |
| 96 | + subject-path: "dist/*" |
| 97 | + # To upload to PyPI without a token, add this workflow file as a Trusted Publisher in the project settings on the PyPI website |
| 98 | + - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
0 commit comments