Skip to content

Commit cf39899

Browse files
author
Ignacio Bonafonte
authored
Automatic version number on GitHub release (open-telemetry#507)
Add script that updates versions and commits changes
1 parent 8b1b833 commit cf39899

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.github/workflows/createRelease.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This workflow will build a Swift project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
3+
4+
name: Create release
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
release:
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Get the tag version
17+
id: tag_version
18+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
19+
- name: Update version
20+
run: sh Scripts/updateVersion.sh $GITHUB_TOKEN ${{ steps.tag_version.outputs.VERSION }}

Scripts/updateVersion.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
# This script expects two inputs
3+
# $1 - The github token for opentelemetry-swift
4+
# $2 - the git tag
5+
6+
#Update version number
7+
sed -E -i '' 's/public static let OTEL_SWIFT_SDK_VERSION = ".+"/public static let OTEL_SWIFT_SDK_VERSION = "'$2\"/ ./Sources/OpenTelemetrySdk/Version.swift
8+
git commit -m "Updated version number to $2"
9+
git tag -f $2
10+
git push -f --tags origin HEAD:main

Sources/OpenTelemetrySdk/Version.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
import Foundation
77

88
extension Resource {
9-
public static let OTEL_SWIFT_SDK_VERSION : String = "1.8.0"
9+
public static let OTEL_SWIFT_SDK_VERSION = "1.8.0"
1010
}

0 commit comments

Comments
 (0)