|
| 1 | +# Copyright (c) 2023 Robert Bosch GmbH |
| 2 | +# |
| 3 | +# This program and the accompanying materials are made available under the |
| 4 | +# terms of the Apache License, Version 2.0 which is available at |
| 5 | +# https://www.apache.org/licenses/LICENSE-2.0. |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | +# |
| 13 | +# SPDX-License-Identifier: Apache-2.0 |
| 14 | + |
| 15 | +name: Create/update tag |
| 16 | +on: |
| 17 | + workflow_dispatch: |
| 18 | + push: |
| 19 | + tags: |
| 20 | + - 'v[0-9]+\.[0-9]+\.[0-9]+' |
| 21 | +jobs: |
| 22 | + create-tag: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + - name: Get version from setup.py |
| 27 | + id: getVersions |
| 28 | + run: | |
| 29 | + semantic_version=$(python setup.py --version) |
| 30 | + major_version=$(cut -d '.' -f 1 <<< "$semantic_version") |
| 31 | + major_minor_version=$(cut -d '.' -f 1,2 <<< "$semantic_version") |
| 32 | + echo "semantic_version=v$semantic_version" >> $GITHUB_OUTPUT |
| 33 | + echo "major_version=v$major_version" >> $GITHUB_OUTPUT |
| 34 | + echo "major_minor_version=v$major_minor_version" >> $GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: Check manual created tag |
| 37 | + id: manualTag |
| 38 | + if: github.ref_type == 'tag' |
| 39 | + run: | |
| 40 | + if [ "${GITHUB_REF#refs/*/}" != ${{ steps.getVersions.outputs.semantic_version }} ]; then |
| 41 | + echo "Please align desired tag: '${GITHUB_REF#refs/*/}' ${{ github.ref }} with setup.py version '${{ steps.getVersions.outputs.semantic_version }}'" |
| 42 | + echo "Deleting manual created tag" |
| 43 | + git push --delete origin ${GITHUB_REF#refs/*/} |
| 44 | + exit 1 |
| 45 | + else |
| 46 | + echo "All fine" |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Create full version tag - ${{ steps.getVersions.outputs.semantic_version }} |
| 50 | + uses: rickstaa/action-create-tag@v1 |
| 51 | + id: "tag_create_full_version" |
| 52 | + with: |
| 53 | + tag: ${{ steps.getVersions.outputs.semantic_version }} |
| 54 | + tag_exists_error: true |
| 55 | + force_push_tag: false |
| 56 | + message: "${{ steps.getVersions.outputs.semantic_version }}" |
| 57 | + |
| 58 | + - name: Create major.minor version tag - ${{ steps.getVersions.outputs.major_minor_version }} |
| 59 | + uses: rickstaa/action-create-tag@v1 |
| 60 | + id: "tag_create_major_minor" |
| 61 | + with: |
| 62 | + tag: ${{ steps.getVersions.outputs.major_minor_version }} |
| 63 | + tag_exists_error: false |
| 64 | + force_push_tag: true |
| 65 | + message: "${{ steps.getVersions.outputs.major_minor_version }}" |
| 66 | + |
| 67 | + - name: Create major version tag - ${{ steps.getVersions.outputs.major_version }} |
| 68 | + uses: rickstaa/action-create-tag@v1 |
| 69 | + id: "tag_create_major" |
| 70 | + with: |
| 71 | + tag: ${{ steps.getVersions.outputs.major_version }} |
| 72 | + tag_exists_error: false |
| 73 | + force_push_tag: true |
| 74 | + message: "${{ steps.getVersions.outputs.major_version }}" |
0 commit comments