# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Adds a tag to main after a PR is merged succesfully.

name: "tag release"

on:
  push:
    branches:
      - main

defaults:
  run:
    shell: bash

jobs:
  create-tag:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Get SDK version and set environment variable
      run: |
        SDK_VERSION=$(grep 'SDK_VERSION' src/Core/GraphConstants.php |  grep -oE '[0-9]+\.[0-9]+\.([0-9]+|[0-9]+-[a-z]+)')
        echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV

    - name: Create and publish tag
      run: |
        echo "SDK_VERSION is:"$SDK_VERSION
        git tag $SDK_VERSION && git push origin $SDK_VERSION