|
| 1 | +name: "Create Tag" |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + module: |
| 6 | + description: 'Module to create tag for' |
| 7 | + required: true |
| 8 | + type: choice |
| 9 | + options: |
| 10 | + - KarteUtilities |
| 11 | + - KarteCore |
| 12 | + - KarteInAppMessaging |
| 13 | + - KarteRemoteNotification |
| 14 | + - KarteVariables |
| 15 | + - KarteVisualTracking |
| 16 | + - KarteInbox |
| 17 | + - KarteInAppFrame |
| 18 | + - KarteCrashReporting |
| 19 | + - KarteNotificationServiceExtension |
| 20 | + - KarteDebugger |
| 21 | + default: 'KarteCore' |
| 22 | + dry_run: |
| 23 | + description: 'Skip tag push (dry-run mode)' |
| 24 | + required: false |
| 25 | + type: boolean |
| 26 | + default: true |
| 27 | +jobs: |
| 28 | + create-tag: |
| 29 | + # Available only on master branch when `dry-run = false`. |
| 30 | + if: github.repository != 'plaidev/karte-ios-sdk' && (github.event.inputs.dry_run == 'true' || github.ref == 'refs/heads/master') |
| 31 | + runs-on: ubuntu-latest |
| 32 | + timeout-minutes: 30 |
| 33 | + steps: |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 36 | + with: |
| 37 | + persist-credentials: false |
| 38 | + fetch-depth: 0 |
| 39 | + - name: Generate GitHub App token |
| 40 | + uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 |
| 41 | + id: app-token |
| 42 | + with: |
| 43 | + app-id: ${{ secrets.APP_TEAM_GITHUB_APP_ID }} |
| 44 | + private-key: ${{ secrets.APP_TEAM_GITHUB_APP_PRIVATE_KEY }} |
| 45 | + owner: plaidev |
| 46 | + repositories: | |
| 47 | + karte-ios-sdk |
| 48 | + karte-ios-dev |
| 49 | + - name: Configure Git |
| 50 | + env: |
| 51 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 52 | + run: | |
| 53 | + git config --global url."https://x-access-token:${GH_TOKEN}@github.com/plaidev/karte-ios-sdk".insteadOf "https://github.com/plaidev/karte-ios-sdk" |
| 54 | + git config --global url."https://x-access-token:${GH_TOKEN}@github.com/plaidev/karte-ios-dev".insteadOf "https://github.com/plaidev/karte-ios-dev" |
| 55 | + git config --global user.name "github actions" |
| 56 | + git config --global user.email "[email protected]" |
| 57 | + - name: Setup remote repository |
| 58 | + run: git remote add sync_repo https://github.com/plaidev/karte-ios-sdk.git |
| 59 | + - name: Generate tag name |
| 60 | + id: tag |
| 61 | + env: |
| 62 | + MODULE: ${{ github.event.inputs.module }} |
| 63 | + run: | |
| 64 | + PODSPEC="${MODULE}.podspec" |
| 65 | + VERSION=$(grep -E "s\.version\s*=" "$PODSPEC" | sed -E "s/.*'([^']+)'.*/\1/") |
| 66 | + PREFIX=$(echo "$MODULE" | sed 's/Karte//') |
| 67 | + TAG_NAME="${PREFIX}-${VERSION}" |
| 68 | + echo "name=${TAG_NAME}" >> $GITHUB_OUTPUT |
| 69 | + echo "Generated tag: ${TAG_NAME} (from ${PODSPEC} version ${VERSION})" |
| 70 | + - name: Check if tag exists |
| 71 | + env: |
| 72 | + TAG: ${{ steps.tag.outputs.name }} |
| 73 | + run: | |
| 74 | + if git ls-remote --tags origin | grep -q "refs/tags/${TAG}$"; then |
| 75 | + echo "Error: Tag ${TAG} already exists on origin" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | + if git ls-remote --tags sync_repo | grep -q "refs/tags/${TAG}$"; then |
| 79 | + echo "Error: Tag ${TAG} already exists on sync_repo" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | + - name: Create and push tag |
| 83 | + if: github.event.inputs.dry_run != 'true' |
| 84 | + env: |
| 85 | + TAG: ${{ steps.tag.outputs.name }} |
| 86 | + run: | |
| 87 | + git tag "${TAG}" |
| 88 | + git push origin "${TAG}" |
| 89 | + git push sync_repo "${TAG}" |
| 90 | + - name: Create and push tag (dry-run) |
| 91 | + if: github.event.inputs.dry_run == 'true' |
| 92 | + env: |
| 93 | + TAG: ${{ steps.tag.outputs.name }} |
| 94 | + run: | |
| 95 | + git tag "${TAG}" |
| 96 | + git push --dry-run origin "${TAG}" |
| 97 | + git push --dry-run sync_repo "${TAG}" |
| 98 | + git tag -d "${TAG}" |
0 commit comments