|
| 1 | +name: Tests, Package, and Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: [next, qa, main] |
| 8 | + tags: ["v*"] |
| 9 | + |
| 10 | +env: |
| 11 | + PKG_NAME: plot-publisher |
| 12 | + MODULE_NAME: plot_publisher |
| 13 | + |
| 14 | +jobs: |
| 15 | + tests: |
| 16 | + name: Unit tests |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + fetch-tags: true |
| 24 | + |
| 25 | + - name: Setup pixi |
| 26 | + uses: prefix-dev/[email protected] |
| 27 | + with: |
| 28 | + pixi-version: v0.50.2 |
| 29 | + manifest-path: pyproject.toml |
| 30 | + |
| 31 | + - name: Run unit tests |
| 32 | + run: pixi run test |
| 33 | + |
| 34 | + - name: Upload coverage to codecov |
| 35 | + uses: codecov/codecov-action@v5 |
| 36 | + if: github.actor != 'dependabot[bot]' |
| 37 | + with: |
| 38 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 39 | + |
| 40 | + conda-build: |
| 41 | + name: Build conda package |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v5 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + fetch-tags: true |
| 49 | + |
| 50 | + - name: Setup pixi |
| 51 | + uses: prefix-dev/[email protected] |
| 52 | + with: |
| 53 | + pixi-version: v0.50.2 |
| 54 | + manifest-path: pyproject.toml |
| 55 | + |
| 56 | + - name: Build conda package |
| 57 | + run: | |
| 58 | + pixi run conda-build |
| 59 | + mkdir -p /tmp/local-channel/linux-64 |
| 60 | + cp *.conda /tmp/local-channel/linux-64 |
| 61 | +
|
| 62 | + - name: Verify conda package |
| 63 | + uses: neutrons/conda-verify@main |
| 64 | + with: |
| 65 | + package-name: ${{ env.PKG_NAME }} |
| 66 | + module-name: ${{ env.MODULE_NAME }} |
| 67 | + local-channel: /tmp/local-channel |
| 68 | + |
| 69 | + - name: Upload conda package as artifact |
| 70 | + uses: actions/upload-artifact@v4 |
| 71 | + with: |
| 72 | + name: artifact-conda-package |
| 73 | + path: ${{ env.PKG_NAME }}-*.conda |
| 74 | + |
| 75 | + publish: |
| 76 | + name: Upload package to anaconda |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: [tests, conda-build] |
| 79 | + if: startsWith(github.ref, 'refs/tags/v') |
| 80 | + steps: |
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v5 |
| 83 | + with: |
| 84 | + fetch-depth: 0 |
| 85 | + fetch-tags: true |
| 86 | + |
| 87 | + - name: Setup Pixi |
| 88 | + uses: prefix-dev/[email protected] |
| 89 | + with: |
| 90 | + pixi-version: v0.50.2 |
| 91 | + manifest-path: pyproject.toml |
| 92 | + |
| 93 | + - name: Download conda package artifact |
| 94 | + uses: actions/download-artifact@v5 |
| 95 | + with: |
| 96 | + name: artifact-conda-package |
| 97 | + |
| 98 | + - name: Upload package to anaconda |
| 99 | + env: |
| 100 | + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} |
| 101 | + IS_RC: ${{ contains(github.ref, 'rc') }} |
| 102 | + run: | |
| 103 | + # label is main or rc depending on the tag-name |
| 104 | + CONDA_LABEL="main" |
| 105 | + if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi |
| 106 | + echo pushing ${{ github.ref }} with label $CONDA_LABEL |
| 107 | + pixi run anaconda upload --label $CONDA_LABEL --user neutrons ${{ env.PKG_NAME }}-*.conda |
0 commit comments