|
5 | 5 | - main
|
6 | 6 | types:
|
7 | 7 | - closed
|
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: tag-note-release-${{ github.event.pull_request.number }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
8 | 13 | permissions:
|
9 | 14 | contents: read
|
10 | 15 | jobs:
|
11 |
| - CheckRelease: |
| 16 | + tag: |
| 17 | + name: Create Tag & Release |
| 18 | + if: > |
| 19 | + github.event.pull_request.merged == true && |
| 20 | + startsWith(github.event.pull_request.head.ref, 'release/') |
| 21 | + runs-on: macos-15 |
12 | 22 | permissions:
|
13 | 23 | contents: write # required for creating tags and releases
|
14 |
| - runs-on: macos-15 |
| 24 | + outputs: |
| 25 | + version: ${{ steps.parse.outputs.version }} |
15 | 26 | steps:
|
16 |
| - - name: Check if merge is release branch |
17 |
| - id: check-release |
| 27 | + - name: Parse version from branch name |
| 28 | + id: parse |
18 | 29 | run: |
|
19 |
| - if [[ ${{ github.head_ref }} =~ ^release/([0-9]+\.[0-9]+\.[0-9]+$) ]]; then |
20 |
| - echo "match=true" >> $GITHUB_OUTPUT |
21 |
| - echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT |
22 |
| - fi |
23 |
| - - name: Tag if release branch |
24 |
| - if: github.event.pull_request.merged != true || steps.check-release.outputs.match != 'true' |
25 |
| - run: exit 1 |
| 30 | + version=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's/^release\///') |
| 31 | + echo "version=$version" >> $GITHUB_OUTPUT |
26 | 32 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
27 | 33 | with:
|
28 | 34 | ref: ${{ github.event.pull_request.merge_commit_sha }}
|
29 |
| - fetch-depth: '0' |
30 |
| - - uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1 |
| 35 | + fetch-depth: '0' |
| 36 | + - name: Check if tag already exists |
| 37 | + id: tag_check |
| 38 | + run: | |
| 39 | + if git rev-parse "refs/tags/${{ steps.parse.outputs.version }}" >/dev/null 2>&1; then |
| 40 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 41 | + else |
| 42 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 43 | + fi |
| 44 | + - name: Create tag |
| 45 | + if: steps.tag_check.outputs.exists == 'false' |
| 46 | + uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1 |
31 | 47 | with:
|
32 |
| - commit_message: version bump to ${{ steps.check-release.outputs.version }} |
33 |
| - tagging_message: '${{ steps.check-release.outputs.version }}' |
34 |
| - - uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0 |
| 48 | + commit_message: version bump to ${{ steps.parse.outputs.version }} |
| 49 | + tagging_message: '${{ steps.parse.outputs.version }}' |
| 50 | + - name: Create release |
| 51 | + if: steps.tag_check.outputs.exists == 'false' |
| 52 | + uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0 |
35 | 53 | with:
|
36 |
| - tag: ${{ steps.check-release.outputs.version }} |
| 54 | + tag: ${{ steps.parse.outputs.version }} |
37 | 55 | prerelease: true
|
38 | 56 | generateReleaseNotes: true
|
39 |
| - - name: push cocoapods |
| 57 | + |
| 58 | + cocoapods: |
| 59 | + name: Publish to CocoaPods |
| 60 | + needs: tag |
| 61 | + runs-on: macos-15 |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 64 | + - name: Publish to CocoaPods trunk |
40 | 65 | env:
|
41 | 66 | COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
|
42 |
| - id: cocoapod_trunk_push |
43 | 67 | run: |
|
44 |
| - pod trunk push OpenTelemetry-Swift-Api.podspec --allow-warnings |
45 |
| - pod trunk push OpenTelemetry-Swift-Sdk.podspec --allow-warnings --synchronous |
46 |
| - pod trunk push OpenTelemetry-Swift-BaggagePropagationProcessor.podspec --allow-warnings --synchronous |
47 |
| - pod trunk push OpenTelemetry-Swift-Instrumentation-NetworkStatus.podspec --allow-warnings --synchronous |
48 |
| - pod trunk push OpenTelemetry-Swift-Instrumentation-URLSession.podspec --allow-warnings --synchronous |
49 |
| - pod trunk push OpenTelemetry-Swift-Protocol-Exporter-Common.podspec --allow-warnings --synchronous |
50 |
| - pod trunk push OpenTelemetry-Swift-SdkResourceExtension.podspec --allow-warnings --synchronous |
51 |
| - pod trunk push OpenTelemetry-Swift-Protocol-Exporter-Http.podspec --allow-warnings --synchronous |
52 |
| - pod trunk push OpenTelemetry-Swift-PersistenceExporter.podspec --allow-warnings --synchronous |
53 |
| - pod trunk push OpenTelemetry-Swift-StdoutExporter.podspec --allow-warnings --synchronous |
| 68 | + VERSION="${{ needs.tag.outputs.version }}" |
| 69 | + failed_pods=() |
| 70 | + |
| 71 | + # Define all pods to publish |
| 72 | + pods=( |
| 73 | + "OpenTelemetry-Swift-BaggagePropagationProcessor" |
| 74 | + "OpenTelemetry-Swift-Instrumentation-NetworkStatus" |
| 75 | + "OpenTelemetry-Swift-Instrumentation-URLSession" |
| 76 | + "OpenTelemetry-Swift-SdkResourceExtension" |
| 77 | + "OpenTelemetry-Swift-Protocol-Exporter-Common" |
| 78 | + "OpenTelemetry-Swift-Protocol-Exporter-Http" |
| 79 | + "OpenTelemetry-Swift-PersistenceExporter" |
| 80 | + "OpenTelemetry-Swift-StdoutExporter" |
| 81 | + ) |
| 82 | + |
| 83 | + # Process each pod |
| 84 | + for pod_name in "${pods[@]}"; do |
| 85 | + echo "Processing $pod_name..." |
| 86 | + |
| 87 | + if pod trunk info "$pod_name" 2>&1 | grep -F " - ${VERSION} (" >/dev/null; then |
| 88 | + echo "::warning::$pod_name '${VERSION}' already exists on CocoaPods. Skipping." |
| 89 | + else |
| 90 | + if ! pod trunk push "${pod_name}.podspec" --allow-warnings --synchronous; then |
| 91 | + echo "::error::Failed to push $pod_name" |
| 92 | + failed_pods+=("$pod_name") |
| 93 | + else |
| 94 | + echo "Successfully pushed $pod_name" |
| 95 | + fi |
| 96 | + fi |
| 97 | + done |
| 98 | + |
| 99 | + # Report results |
| 100 | + if [ ${#failed_pods[@]} -gt 0 ]; then |
| 101 | + echo "::error::The following pods failed to publish: ${failed_pods[*]}" |
| 102 | + exit 1 |
| 103 | + else |
| 104 | + echo "All pods published successfully!" |
| 105 | + fi |
54 | 106 |
|
0 commit comments