|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [closed] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + if: > |
| 13 | + github.event.pull_request.merged == true && ( |
| 14 | + contains(github.event.pull_request.labels.*.name, 'release:patch') || |
| 15 | + contains(github.event.pull_request.labels.*.name, 'release:major') |
| 16 | + ) |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: true |
| 20 | + |
| 21 | + steps: |
| 22 | + # 1. Checkout the merged code |
| 23 | + - name: Checkout merged code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + ref: ${{ github.event.pull_request.base.ref }} |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + # 2. Setup environment |
| 30 | + - name: Set up Pixi |
| 31 | + uses: prefix-dev/setup-pixi@v0.8.9 |
| 32 | + |
| 33 | + - name: Fetch bot identity |
| 34 | + id: bot |
| 35 | + uses: raven-actions/bot-details@v1 |
| 36 | + |
| 37 | + - name: Configure git for committing |
| 38 | + run: | |
| 39 | + git config user.name "${{ steps.bot.outputs.name }}" |
| 40 | + git config user.email "${{ steps.bot.outputs.email }}" |
| 41 | +
|
| 42 | + # 3. Bump version |
| 43 | + - name: Bump version (patch) |
| 44 | + if: contains(github.event.pull_request.labels.*.name, 'release:patch') |
| 45 | + run: pixi run -e build bumpver update --patch |
| 46 | + |
| 47 | + - name: Bump version (major) |
| 48 | + if: contains(github.event.pull_request.labels.*.name, 'release:major') |
| 49 | + run: pixi run -e build bumpver update --major |
| 50 | + |
| 51 | + - name: Get version |
| 52 | + id: version |
| 53 | + run: | |
| 54 | + echo "tag=$(pixi run current-version)" >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + # 4. Build and upload conda package |
| 57 | + - name: Build |
| 58 | + run: | |
| 59 | + pixi build |
| 60 | +
|
| 61 | + - name: Upload |
| 62 | + run: | |
| 63 | + pixi run -e build upload |
| 64 | + env: |
| 65 | + ANACONDA_API_KEY: ${{ secrets.ANACONDA_API_KEY }} |
| 66 | + |
| 67 | + # 5. Create release |
| 68 | + - name: Create GitHub Release |
| 69 | + uses: softprops/action-gh-release@v2 |
| 70 | + with: |
| 71 | + tag_name: ${{ steps.version.outputs.tag }} |
0 commit comments