Skip to content

Commit

Permalink
Automatic version number on GitHub release (#507)
Browse files Browse the repository at this point in the history
Add script that updates versions and commits changes
  • Loading branch information
Ignacio Bonafonte authored Jan 18, 2024
1 parent 8b1b833 commit cf39899
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/createRelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: Create release

on:
release:
types: [created]

jobs:
release:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- name: Get the tag version
id: tag_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Update version
run: sh Scripts/updateVersion.sh $GITHUB_TOKEN ${{ steps.tag_version.outputs.VERSION }}
10 changes: 10 additions & 0 deletions Scripts/updateVersion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# This script expects two inputs
# $1 - The github token for opentelemetry-swift
# $2 - the git tag

#Update version number
sed -E -i '' 's/public static let OTEL_SWIFT_SDK_VERSION = ".+"/public static let OTEL_SWIFT_SDK_VERSION = "'$2\"/ ./Sources/OpenTelemetrySdk/Version.swift
git commit -m "Updated version number to $2"
git tag -f $2
git push -f --tags origin HEAD:main
2 changes: 1 addition & 1 deletion Sources/OpenTelemetrySdk/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
import Foundation

extension Resource {
public static let OTEL_SWIFT_SDK_VERSION : String = "1.8.0"
public static let OTEL_SWIFT_SDK_VERSION = "1.8.0"
}

0 comments on commit cf39899

Please sign in to comment.