a b/.github/workflows/deploy.yml
1
---
2
name: Deploy workflow
3
on:
4
  workflow_dispatch:
5
    inputs:
6
      comments:
7
        description: "Comments"
8
      branch:
9
        description: The branch from which to make the release
10
        required: true
11
        default: master
12
13
jobs:
14
  release_changelog:
15
    runs-on: ubuntu-latest
16
17
    steps:
18
      - name: Print author
19
        run: |
20
          echo "Author: ${{ github.triggering_actor }}"
21
          echo "Comments: ${{ github.event.inputs.comments }}"
22
23
      - uses: actions/checkout@v4
24
        with:
25
          ref: ${{ github.event.inputs.branch }}
26
27
      - name: Draft change log
28
        uses: release-drafter/release-drafter@v5
29
        id: release-drafter
30
        with:
31
          commitish: ${{ github.event.inputs.branch }}
32
        env:
33
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
35
      # Can replace the below with (until pipeline description) with
36
      # khanlab/actions/.github/workflows/workflow-version_task-publishGithub.yml
37
      # after adding PAT token
38
      - name: Set new release version
39
        env:
40
          RD_RELEASE: ${{ steps.release-drafter.outputs.name }}
41
        run: |
42
          if [ ! -z "$RD_RELEASE" ]; then
43
            echo "NEW_RELEASE=$RD_RELEASE" >> $GITHUB_ENV
44
          else
45
            echo "NEW_RELEASE=0.1.0" >> $GITHUB_ENV
46
          fi
47
48
      - name: Update version in pyproject.toml
49
        uses: jacobtomlinson/gha-find-replace@v3
50
        with:
51
          include: "pyproject.toml"
52
          find: 'version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
53
          replace: 'version = "${{ env.NEW_RELEASE }}"'
54
55
      - name: Update version in pipeline_description (not actually used)
56
        uses: jacobtomlinson/gha-find-replace@v3
57
        with:
58
          include: "hippunfold/pipeline_description.json"
59
          find: '"Version": "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
60
          replace: '"Version": "${{ env.NEW_RELEASE }}"'
61
62
      - name: Update version in config/snakebids.yml
63
        uses: jacobtomlinson/gha-find-replace@v3
64
        with:
65
          include: "hippunfold/config/snakebids.yml"
66
          find: 'version: "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
67
          replace: 'version: "${{ env.NEW_RELEASE }}"'
68
69
      - name: Commit updates
70
        env:
71
          LATEST_VERSION: ${{ env.NEW_RELEASE }}
72
        run: |
73
          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
74
          git config --local user.name "github-actions[bot]"
75
          git diff-index --quiet HEAD || git commit -m "Bump version to $LATEST_VERSION" -a
76
77
      - name: Push changes
78
        uses: ad-m/github-push-action@v0.8.0
79
        with:
80
          github_token: ${{ secrets.GITHUB_TOKEN }}
81
82
      - name: Publish change log
83
        uses: release-drafter/release-drafter@v5
84
        with:
85
          publish: true
86
        env:
87
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}