|
| 1 | +--- |
| 2 | + |
| 3 | +name: 'Bump' |
| 4 | + |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + CZ_PRE_RELEASE: |
| 10 | + default: none |
| 11 | + required: false |
| 12 | + description: Create Pre-Release {alpha,beta,rc,none} |
| 13 | + type: string |
| 14 | + CZ_INCREMENT: |
| 15 | + default: none |
| 16 | + required: false |
| 17 | + description: Type of increment to conduct {MAJOR,MINOR,PATCH,none} |
| 18 | + type: string |
| 19 | + secrets: |
| 20 | + WORKFLOW_TOKEN: |
| 21 | + description: Token used to create the tag (required to trigger 'tag' workflow) |
| 22 | + required: true |
| 23 | + |
| 24 | + |
| 25 | +jobs: |
| 26 | + |
| 27 | + bump: |
| 28 | + name: 'Bump Version' |
| 29 | + if: github.event.commits[0].author.name != 'nfc-bot' |
| 30 | + runs-on: ubuntu-latest |
| 31 | + outputs: |
| 32 | + version-current: ${{ steps.version-current.outputs.value-out }} |
| 33 | + version-new: ${{ steps.version-new.outputs.value-out }} |
| 34 | + steps: |
| 35 | + |
| 36 | + |
| 37 | + - name: Checkout Code - ${{ github.ref_name }} Branch |
| 38 | + if: ${{ github.ref_name == 'master' }} |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + fetch-depth: 0 |
| 42 | + fetch-tags: true |
| 43 | + token: ${{ secrets.WORKFLOW_TOKEN }} |
| 44 | + ref: development |
| 45 | + |
| 46 | + |
| 47 | + - name: Checkout Code - ${{ github.ref_name }} Branch |
| 48 | + if: ${{ github.ref_name != 'master' }} |
| 49 | + uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + fetch-depth: 0 |
| 52 | + fetch-tags: true |
| 53 | + token: ${{ secrets.WORKFLOW_TOKEN }} |
| 54 | + ref: ${{ github.ref_name }} |
| 55 | + |
| 56 | + |
| 57 | + - name: Install Commitizen |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + pip install \ |
| 61 | + commitizen==3.28.0 |
| 62 | +
|
| 63 | +
|
| 64 | + - name: Fetch Current Version |
| 65 | + id: version-current |
| 66 | + run: | |
| 67 | + echo "value-out=$(cz version --project)" >> $GITHUB_OUTPUT |
| 68 | +
|
| 69 | +
|
| 70 | + - name: Increment version with .cz.yaml |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + if [ "${{ inputs.CZ_PRE_RELEASE }}" != 'none' ]; then |
| 74 | +
|
| 75 | + if [ "0${{ inputs.CZ_PRE_RELEASE }}" != '0' ]; then |
| 76 | +
|
| 77 | + echo "[debug] Pre-Release detected: ${{ inputs.CZ_PRE_RELEASE }}"; |
| 78 | +
|
| 79 | + export pre_release="--prerelease ${{ inputs.CZ_PRE_RELEASE }}"; |
| 80 | +
|
| 81 | + fi; |
| 82 | +
|
| 83 | + fi; |
| 84 | +
|
| 85 | + if [ "${{ inputs.CZ_INCREMENT }}" != 'none' ]; then |
| 86 | +
|
| 87 | + if [ "0${{ inputs.CZ_PRE_RELEASE }}" != '0' ]; then |
| 88 | +
|
| 89 | + echo "[debug] Pre-Release detected: ${{ inputs.CZ_INCREMENT }}"; |
| 90 | +
|
| 91 | + export increment="--increment ${{ inputs.CZ_INCREMENT }}"; |
| 92 | +
|
| 93 | + fi; |
| 94 | +
|
| 95 | + fi; |
| 96 | +
|
| 97 | + cz bump \ |
| 98 | + --files-only \ |
| 99 | + ${pre_release} \ |
| 100 | + ${increment} \ |
| 101 | + --yes; |
| 102 | +
|
| 103 | +
|
| 104 | + - name: Fetch Current Version |
| 105 | + id: version-new |
| 106 | + run: | |
| 107 | + echo "value-out=$(cz version --project)" >> $GITHUB_OUTPUT |
| 108 | +
|
| 109 | +
|
| 110 | + - name: ls |
| 111 | + if: ${{ github.ref_name != 'master' }} |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + ls -la |
| 115 | +
|
| 116 | +
|
| 117 | + - name: Update Changelog |
| 118 | + shell: bash |
| 119 | + run: | |
| 120 | + cz changelog --dry-run --incremental --unreleased-version "${{ steps.version-new.outputs.value-out }}" > changelog-release.md |
| 121 | +
|
| 122 | +
|
| 123 | + - name: Update Changelog |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + cz changelog --unreleased-version "${{ steps.version-new.outputs.value-out }}" |
| 127 | +
|
| 128 | +
|
| 129 | + - name: Upload Release Changelog |
| 130 | + if: ${{ steps.version-new.outputs.value-out }} |
| 131 | + uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: changelog-release |
| 134 | + path: changelog-release.md |
| 135 | + |
| 136 | + |
| 137 | + - name: Create Release Changelog |
| 138 | + if: ${{ steps.version-new.outputs.value-out }} |
| 139 | + shell: bash |
| 140 | + run: | |
| 141 | + rm changelog-release.md; |
| 142 | + git status; |
| 143 | +
|
| 144 | +
|
| 145 | + - name: Run Additional Actions |
| 146 | + if: ${{ steps.version-current.outputs.value-out != steps.version-new.outputs.value-out }} |
| 147 | + shell: bash |
| 148 | + run: | |
| 149 | + echo 'run script'; |
| 150 | + if [ -f .github/additional_actions_bump.sh ]; then |
| 151 | +
|
| 152 | + echo "[Info] Set ENV vars for script's usage"; |
| 153 | +
|
| 154 | + export CURRENT_VERSION=${{ steps.version-current.outputs.value-out }} |
| 155 | +
|
| 156 | + export NEW_VERSION=${{ steps.version-new.outputs.value-out }} |
| 157 | +
|
| 158 | + echo "[Info] ***************************************"; |
| 159 | +
|
| 160 | + echo "[Debug]CURRENT_VERSION=${CURRENT_VERSION}"; |
| 161 | +
|
| 162 | + echo "[Debug]NEW_VERSION=${NEW_VERSION}"; |
| 163 | +
|
| 164 | + echo "[Info] ***************************************"; |
| 165 | +
|
| 166 | + chmod +x .github/additional_actions_bump.sh |
| 167 | +
|
| 168 | + echo "[Debug] found additional action script .github/additional_actions_bump.sh"; |
| 169 | +
|
| 170 | + echo "[Info] ***************************************"; |
| 171 | + echo "[Debug] cat .github/additional_actions_bump.sh"; |
| 172 | + echo "[Info] *************"; |
| 173 | +
|
| 174 | + echo "[Debug] $(cat .github/additional_actions_bump.sh)"; |
| 175 | +
|
| 176 | + echo "[Info] *************"; |
| 177 | + echo "[Info] ***************************************"; |
| 178 | +
|
| 179 | + .github/additional_actions_bump.sh |
| 180 | +
|
| 181 | + fi |
| 182 | +
|
| 183 | +
|
| 184 | + - name: Commit the changelog |
| 185 | + if: ${{ steps.version-new.outputs.value-out && github.ref_name == 'master' }} |
| 186 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 187 | + with: |
| 188 | + commit_message: 'build: bump version ${{ steps.version-current.outputs.value-out }} -> ${{ steps.version-new.outputs.value-out }}' |
| 189 | + branch: development |
| 190 | + # file_pattern: '.' |
| 191 | + commit_user_name: nfc-bot |
| 192 | + commit_user_email: [email protected] |
| 193 | + commit_author: nfc-bot <[email protected]> |
| 194 | + tagging_message: ${{ steps.version-new.outputs.value-out }} |
| 195 | + skip_dirty_check: true |
| 196 | + skip_fetch: true |
| 197 | + skip_checkout: true |
| 198 | + disable_globbing: true |
| 199 | + |
| 200 | + |
| 201 | + - name: Commit the changelog |
| 202 | + if: ${{ steps.version-new.outputs.value-out && github.ref_name != 'master'}} |
| 203 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 204 | + with: |
| 205 | + commit_message: 'build: bump version ${{ steps.version-current.outputs.value-out }} -> ${{ steps.version-new.outputs.value-out }}' |
| 206 | + branch: ${{ github.ref_name }} |
| 207 | + # file_pattern: '.' |
| 208 | + commit_user_name: nfc-bot |
| 209 | + commit_user_email: [email protected] |
| 210 | + commit_author: nfc-bot <[email protected]> |
| 211 | + tagging_message: ${{ steps.version-new.outputs.value-out }} |
| 212 | + skip_dirty_check: true |
| 213 | + skip_fetch: true |
| 214 | + skip_checkout: true |
| 215 | + disable_globbing: true |
| 216 | + |
| 217 | + |
| 218 | + - name: Configure git |
| 219 | + shell: bash |
| 220 | + run: | |
| 221 | + git config --global user.email "[email protected]"; |
| 222 | + git config --global user.name "nfc-bot"; |
| 223 | +
|
| 224 | +
|
| 225 | + - name: Checkout master |
| 226 | + if: ${{ github.ref_name == 'master' }} |
| 227 | + shell: bash |
| 228 | + run: | |
| 229 | + git checkout master; |
| 230 | +
|
| 231 | +
|
| 232 | + - name: Merge changes to master |
| 233 | + if: ${{ github.ref_name == 'master' }} |
| 234 | + shell: bash |
| 235 | + run: | |
| 236 | + git merge --no-ff development; |
| 237 | +
|
| 238 | +
|
| 239 | + - name: Push changes |
| 240 | + if: ${{ github.ref_name == 'master' }} |
| 241 | + shell: bash |
| 242 | + run: | |
| 243 | + git push origin master; |
0 commit comments