|
| 1 | +name: merge_release |
| 2 | +# Create a new release of the github-actions module |
| 3 | + |
| 4 | +# yamllint disable-line rule:truthy |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + types: |
| 8 | + - closed |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + if_merged: |
| 14 | + if: github.event.pull_request.merged |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: 'Get data' |
| 18 | + id: data |
| 19 | + env: |
| 20 | + TITLE: ${{github.event.pull_request.title}} |
| 21 | + run: | |
| 22 | + # Get data |
| 23 | + if [[ "${TITLE}" != "Update github-actions to "* ]]; then |
| 24 | + echo "skip=true" | tee -a "${GITHUB_OUTPUTS}" |
| 25 | + fi |
| 26 | + # shellcheck disable=SC2001 |
| 27 | + VERSION=$(echo "${TITLE}"|sed -e 's|.* ||') |
| 28 | + # shellcheck disable=SC2016 |
| 29 | + MAJOR=${echo "${VERSION}"|awk -F '.' '{print $1}'} |
| 30 | + # shellcheck disable=SC2016 |
| 31 | + MINOR=${echo "${VERSION}"|awk -F '.' '{print $2}'} |
| 32 | + # shellcheck disable=SC2016 |
| 33 | + PATCH=${echo "${VERSION}"|awk -F '.' '{print $3}'} |
| 34 | + echo "version=${VERSION}" | tee -a "${GITHUB_OUTPUTS}" |
| 35 | + echo "major=${MAJOR}" | tee -a "${GITHUB_OUTPUTS}" |
| 36 | + echo "minor=${MINOR}" | tee -a "${GITHUB_OUTPUTS}" |
| 37 | + echo "patch=${PATCH}" | tee -a "${GITHUB_OUTPUTS}" |
| 38 | +
|
| 39 | + - name: 'Checkout testplan defaults' |
| 40 | + if: ${{ steps.data.outputs.skip != 'true' }} |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + repository: 'OXID-eSales/github-actions' |
| 44 | + ref: 'main' |
| 45 | + path: 'github-actions' |
| 46 | + |
| 47 | + - name: 'Tagging' |
| 48 | + if: ${{ steps.data.outputs.skip != 'true' }} |
| 49 | + run: | |
| 50 | + # Tagging |
| 51 | + VERSION="${{steps.data.outputs.major}}.${{steps.data.outputs.minor}}.${{steps.data.outputs.patch}}" |
| 52 | + git tag -a "v${VERSION}" -m "Release v${VERSION}" |
| 53 | + CHECK=$(git tag --list|grep "v${{steps.data.outputs.major}}.${{steps.data.outputs.minor}}"||true) |
| 54 | + if [ -n "${CHECK}" ]; then |
| 55 | + echo "Moving tag v${{steps.data.outputs.major}}.${{steps.data.outputs.minor}}" |
| 56 | + git push --delete origin v${{steps.data.outputs.major}}.${{steps.data.outputs.minor}} |
| 57 | + git tag -d v${{steps.data.outputs.major}}.${{steps.data.outputs.minor}} |
| 58 | + fi |
| 59 | + git tag -a v${{steps.data.outputs.major}}.${{steps.data.outputs.minor}} -m "Release v${VERSION}" |
| 60 | + CHECK=$(git tag --list|grep "v${{steps.data.outputs.major}}"||true) |
| 61 | + if [ -n "${CHECK}" ]; then |
| 62 | + echo "Moving tag v${{steps.data.outputs.major}}" |
| 63 | + git push --delete origin v${{steps.data.outputs.major}} |
| 64 | + git tag -d v${{steps.data.outputs.major}} |
| 65 | + fi |
| 66 | + git tag -a v${{steps.data.outputs.major}} -m "Release v${VERSION}" |
| 67 | + git push --tags |
| 68 | +
|
| 69 | + - uses: ncipollo/release-action@v1 |
| 70 | + if: ${{ steps.data.outputs.skip != 'true' }} |
| 71 | + with: |
| 72 | + token: ${{github.token}} |
| 73 | + tag: 'v${{steps.data.outputs.major}}.${{steps.data.outputs.minor}}.${{steps.data.outputs.patch}}' |
0 commit comments