File: version-bump.yml

package info (click to toggle)
rocm-docs-core 1.31.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 2,728 kB
  • sloc: python: 2,002; sh: 199; javascript: 152; cpp: 29; makefile: 27
file content (120 lines) | stat: -rw-r--r-- 4,203 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Version Bump

on:
  push:
    branches:
      - "main"
  workflow_dispatch:

jobs:
  bump-version:
    name: "Bump version and create changelog with commitizen"
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    concurrency: bump-version
    runs-on: ubuntu-latest
    env:
      PYTHON_VERSION: "3.10"
    outputs:
      bumped: ${{ steps.cz-bump.outputs.bumped }}
      revision: ${{ steps.cz-bump.outputs.revision }}
      sha: ${{ steps.cz-bump.outputs.sha }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "${{ env.PYTHON_VERSION }}"
          cache: pip
          cache-dependency-path: |
            pyproject.toml
            requirements.txt
      - name: Set up cache
        uses: actions/cache@v4.2.0
        with:
          path: .venv
          key: venv-${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml','requirements.txt') }}
      - name: Create virtual env, install requirements
        shell: sh
        run: |
          python -m venv .venv
          . .venv/bin/activate
          python -m pip install pip-tools
          python -m piptools sync requirements.txt
          echo "PATH=$PATH" >> "$GITHUB_ENV"
      - name: Bump version and generate changelog
        shell: sh
        id: cz-bump
        run: |
          git config --local user.name "github-actions[bot]"
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          RESULT=0
          # Answer yes if asked if this is the first tag created
          cz bump --yes --changelog-to-stdout > body.md || RESULT=$?
          if [ "$RESULT" -eq 0 ]; then
            echo "bumped=true" >> "$GITHUB_OUTPUT"
            echo "revision=v$(cz version --project)" >> "$GITHUB_OUTPUT"
            echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
          # https://commitizen-tools.github.io/commitizen/exit_codes/
          # NoneIncrementExit(21): No need to increment the version number
          elif [ "$RESULT" -eq 21 ]; then
            echo "bumped=false" >> "$GITHUB_OUTPUT"
          else
            exit $RESULT
          fi
      - name: Push changes
        if: steps.cz-bump.outputs.bumped == 'true'
        shell: sh
        run: |
          git push --atomic origin "HEAD:${{ github.ref }}" \
            "${{ steps.cz-bump.outputs.revision }}"
      - name: Release
        if: steps.cz-bump.outputs.bumped == 'true'
        uses: softprops/action-gh-release@v0.1.15
        with:
          body_path: "body.md"
          tag_name: ${{ steps.cz-bump.outputs.revision }}

  call-release:
    name: Trigger a Release
    needs: [bump-version]
    if: needs.bump-version.outputs.bumped == 'true'
    uses: ./.github/workflows/release.yml
    with:
      revision: ${{ needs.bump-version.outputs.revision }}
    secrets:
      PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

  mark-status-checks:
    name: Mark required status checks as succeeded
    needs: [bump-version]
    runs-on: ubuntu-latest
    if: needs.bump-version.outputs.bumped == 'true'
    steps:
    - shell: sh
      run: |
        REPO="${{ github.repository }}"
        SHA="${{ needs.bump-version.outputs.sha }}"

        printf '%s' "${{ vars.REQUIRED_CHECK_CONTEXTS }}" | \
        while IFS="" read -r CONTEXT; do
          # Mark each check as succeeded
          gh api "/repos/$REPO/statuses/$SHA"                     \
            --method POST                                         \
            --header "Accept: application/vnd.github+json"        \
            --header "X-GitHub-Api-Version: 2022-11-28"           \
            --field state=success                                 \
            --field description='Skipped for version bump commit' \
            --raw-field context="$CONTEXT"
        done
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  call-sync-branches:
    name: Trigger merge
    needs: [bump-version, mark-status-checks]
    if: needs.bump-version.outputs.bumped == 'true'
    uses: ./.github/workflows/sync_branches.yml
    with:
      sha: ${{ needs.bump-version.outputs.sha }}