|
| 1 | +name: Update version and create release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: |
| 7 | + - master |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + fetch-version: |
| 12 | + if: github.event.pull_request.merged |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: Fetch latest release version |
| 17 | + id: fetch-latest-release |
| 18 | + uses: reloc8/action-latest-release-version@1.0.0 |
| 19 | + - uses: actions/setup-python@v2 |
| 20 | + with: |
| 21 | + python-version: 3.7 |
| 22 | + - name: Choose new release version |
| 23 | + id: choose-release-version |
| 24 | + uses: reloc8/action-choose-release-version@1.0.0 |
| 25 | + with: |
| 26 | + source-branch: ${{ github.event.pull_request.head.ref }} |
| 27 | + latest-version: ${{ steps.fetch-latest-release.outputs.latest-release }} |
| 28 | + outputs: |
| 29 | + new-version: ${{ steps.choose-release-version.outputs.new-version }} |
| 30 | + |
| 31 | + update-version: |
| 32 | + needs: fetch-version |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v2 |
| 36 | + - run: git pull --ff-only |
| 37 | + - name: Update version file |
| 38 | + run: echo ${{ needs.fetch-version.outputs.new-version }} > version |
| 39 | + - name: Push local repository changes |
| 40 | + id: push-local-repository-changes |
| 41 | + uses: reloc8/action-push-local-changes@1.0.0 |
| 42 | + env: |
| 43 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + with: |
| 45 | + commit-message: "Version ${{ needs.fetch-version.outputs.new-version }}" |
| 46 | + outputs: |
| 47 | + commit-hash: ${{ steps.push-local-repository-changes.outputs.commit-hash }} |
| 48 | + |
| 49 | + create-release: |
| 50 | + needs: [fetch-version, update-version] |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v2 |
| 54 | + - run: git pull --ff-only |
| 55 | + - name: Create new release |
| 56 | + uses: actions/create-release@v1 |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + with: |
| 60 | + tag_name: ${{ needs.fetch-version.outputs.new-version }} |
| 61 | + release_name: ${{ needs.fetch-version.outputs.new-version }} |
| 62 | + draft: false |
| 63 | + prerelease: false |
| 64 | + commitish: ${{ needs.update-version.outputs.commit-hash }} |
0 commit comments