Skip to content

Automation

Automation #213

Workflow file for this run

name: Automation
on:
schedule:
# Everyday at 9:00 AM UTC
- cron: "0 9 * * *"
workflow_dispatch:
inputs:
tag:
description: 'open-telemetry/opentelemetry-swift tag to build'
required: false
push:
branches:
# For testing purposes, use your branch name here
- "ganeshnj/feat/macos-support"
env:
GH_TOKEN: ${{ github.token }}
jobs:
build:
runs-on: macos-12
steps:
- name: Environment information
run: |
echo "macOS system version information"
sw_vers
echo "Xcode version"
xcodebuild -version
echo "Xcode build tools"
xcodebuild -showsdks
echo "Swift version"
swift --version
- name: Get latest release on opentelemetry-swift
run: |
tag=${{ github.event.inputs.tag }}
# if tag is not provided, get the latest release tag
if [ -z "$tag" ]; then
detected_tag=$(gh api repos/open-telemetry/opentelemetry-swift/releases | jq -r '.[0].tag_name')
if [ -z "$detected_tag" ]; then
echo "Failed to get latest release tag on opentelemetry-swift"
exit 1
fi
echo "Detected $detected_tag as latest release tag on opentelemetry-swift"
tag=$detected_tag
fi
echo "Using $tag as opentelemetry-swift ref"
echo "OTEL_SWIFT_TAG=$tag" >> $GITHUB_ENV
- name: Check if release already exists
run: |
if gh release view ${{ env.OTEL_SWIFT_TAG }} --repo datadog/opentelemetry-swift-packages >/dev/null 2>&1; then
echo "Release ${{ env.OTEL_SWIFT_TAG }} already exists"
echo "SKIP_RELEASE=true" >> $GITHUB_ENV
fi
- name: Checkout self
uses: actions/checkout@v4
with:
path: opentelemetry-swift-packages
- name: Checkout opentelemetry-swift
uses: actions/checkout@v4
with:
repository: open-telemetry/opentelemetry-swift
path: opentelemetry-swift
ref: ${{ env.OTEL_SWIFT_TAG }}
fetch-depth: 0
fetch-tags: true
- name: Build
if: ${{ env.SKIP_RELEASE != 'true' }}
working-directory: ./opentelemetry-swift-packages
run: |
./scripts/build.sh --source ../opentelemetry-swift --target OpenTelemetryApi
- name: Upload artifacts
if: ${{ env.SKIP_RELEASE != 'true' }}
uses: actions/upload-artifact@v4
with:
name: OpenTelemetryApi
path: |
./opentelemetry-swift-packages/artifacts/OpenTelemetryApi.zip
if-no-files-found: error
- name: Prepare
if: ${{ env.SKIP_RELEASE != 'true' }}
working-directory: ./opentelemetry-swift-packages
run: |
git config --global user.name "Datadog SDK Bot"
git config --global user.email "noreply@datadoghq.com"
./scripts/prepare.sh --version ${{ env.OTEL_SWIFT_TAG }}
- name: Verify
if: ${{ env.SKIP_RELEASE != 'true' }}
working-directory: ./opentelemetry-swift-packages
run: |
./scripts/verify.sh
- name: Publish
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
working-directory: ./opentelemetry-swift-packages
run: |
./scripts/publish.sh --version ${{ env.OTEL_SWIFT_TAG }}