Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 90 additions & 27 deletions .github/workflows/Tag-And-Release.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,109 @@
name: Tag & Note Release
on :
pull_request:

on:
pull_request:
branches:
- main
types:
- closed

permissions:
contents: read

concurrency:
group: tag-note-release-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
CheckRelease:
tag:
name: Create Tag & Release
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
permissions:
contents: write # required for creating tags and releases
runs-on: macos-15
contents: write # required for creating tags and releases
outputs:
version: ${{ steps.parse.outputs.version }}
steps:
- name: Check if merge is release branch
id: check-release
- name: Parse version from branch (release/x.y.z)
id: parse
run: |
if [[ ${{ github.head_ref }} =~ ^release/([0-9]+\.[0-9]+\.[0-9]+$) ]]; then
echo "match=true" >> $GITHUB_OUTPUT
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
set -euo pipefail
REF="${{ github.event.pull_request.head.ref }}"
if [[ "$REF" =~ ^release/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "Head branch must follow the format: release/x.y.z (got: $REF)"
exit 1
fi
- name: Tag if release branch
if: github.event.pull_request.merged != true || steps.check-release.outputs.match != 'true'
run: exit 1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Checkout merge commit
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: '0'
- uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
fetch-depth: 0

- name: Check if tag exists remotely
id: check-tag
run: |
set -euo pipefail
VERSION="${{ steps.parse.outputs.version }}"
if git ls-remote --exit-code --tags origin "refs/tags/${VERSION}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag ${VERSION} already exists on origin"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Create and push tag
if: steps.check-tag.outputs.exists != 'true'
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0
with:
commit_message: version bump to ${{ steps.check-release.outputs.version }}
tagging_message: '${{ steps.check-release.outputs.version }}'
- uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0
commit_message: version bump to ${{ steps.parse.outputs.version }}
tagging_message: '${{ steps.parse.outputs.version }}'

- name: Create GitHub Release
if: steps.check-tag.outputs.exists != 'true'
uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0
with:
tag: ${{ steps.check-release.outputs.version }}
tag: ${{ steps.parse.outputs.version }}
prerelease: true
generateReleaseNotes: true
- name: push cocoapods
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
id: cocoapod_trunk_push

cocoapods:
name: Push CocoaPods
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
needs: tag
runs-on: macos-15
permissions:
contents: read
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
VERSION: ${{ needs.tag.outputs.version }}
steps:
- name: Checkout at tag
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ needs.tag.outputs.version }}
fetch-depth: 0

- name: Push OpenTelemetry-Swift-Api if not exists
run: |
set -euo pipefail
if pod trunk info OpenTelemetry-Swift-Api 2>&1 | grep -F " - ${VERSION} (" >/dev/null; then
echo "::warning::OpenTelemetry-Swift-Api '${VERSION}' already exists on CocoaPods. Skipping."
else
pod trunk push OpenTelemetry-Swift-Api.podspec --allow-warnings
fi

- name: Push OpenTelemetry-Swift-Sdk if not exists
run: |
pod trunk push OpenTelemetry-Swift-Api.podspec --allow-warnings
pod trunk push OpenTelemetry-Swift-Sdk.podspec --allow-warnings --synchronous

set -euo pipefail
if pod trunk info OpenTelemetry-Swift-Sdk 2>&1 | grep -F " - ${VERSION} (" >/dev/null; then
echo "::warning::OpenTelemetry-Swift-Sdk '${VERSION}' already exists on CocoaPods. Skipping."
else
pod trunk push OpenTelemetry-Swift-Sdk.podspec --allow-warnings --synchronous
fi
Loading