Skip to content

Commit 934eee4

Browse files
authored
chore(ci): Use env vars instead of direct interpolation in run commands (#6388)
1 parent 3e57e15 commit 934eee4

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

.github/workflows/build-xcframework-variant-slices.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,25 @@ jobs:
7777

7878
- name: Get version
7979
id: get-version
80+
env:
81+
GITHUB_SHA: ${{ github.sha }}
82+
RELEASE_VERSION: ${{ inputs.release-version }}
8083
run: |
81-
if [ -n "${{ inputs.release-version }}" ]; then
82-
echo "VERSION=${{ inputs.release-version }}" >> $GITHUB_ENV
84+
if [ -n "$RELEASE_VERSION" ]; then
85+
echo "VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
8386
else
84-
echo "VERSION=$(grep MARKETING_VERSION Sources/Configuration/Versioning.xcconfig | cut -d ' ' -f 3)+${{ github.sha }}" >> $GITHUB_ENV
87+
echo "VERSION=$(grep MARKETING_VERSION Sources/Configuration/Versioning.xcconfig | cut -d ' ' -f 3)+$GITHUB_SHA" >> $GITHUB_ENV
8588
fi
8689
shell: sh
8790

8891
- name: Compute cache key
92+
env:
93+
RUNNER_OS: ${{ runner.os }}
94+
VARIANT_ID: ${{ inputs.variant-id }}
95+
MATRIX_SDK: ${{ matrix.sdk }}
96+
VERSION: ${{ env.VERSION }}
8997
run: |
90-
echo "SENTRY_XCFRAMEWORK_CACHE_KEY=${{ runner.os }}-xcframework-${{inputs.variant-id}}-slice-${{matrix.sdk}}-${{ env.VERSION }}-${{hashFiles('Sources/**')}}-${{hashFiles('Sentry.xcodeproj/**')}}" >> $GITHUB_ENV
98+
echo "SENTRY_XCFRAMEWORK_CACHE_KEY=${RUNNER_OS}-xcframework-${VARIANT_ID}-slice-${MATRIX_SDK}-${VERSION}-${{hashFiles('Sources/**')}}-${{hashFiles('Sentry.xcodeproj/**')}}" >> $GITHUB_ENV
9199
92100
- name: Restore xcarchive cache
93101
id: cache-xcarchive
@@ -98,28 +106,43 @@ jobs:
98106

99107
- name: Bump version
100108
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
109+
env:
110+
VERSION: ${{ env.VERSION }}
101111
run: |
102112
./scripts/ci-select-xcode.sh 15.2
103-
make bump-version TO=${{ env.VERSION }}
113+
make bump-version TO=$VERSION
104114
105115
- name: Build ${{inputs.name}}${{inputs.suffix}} XCFramework slice for ${{matrix.sdk}}
106116
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
107-
run: ./scripts/build-xcframework-slice.sh ${{matrix.sdk}} ${{inputs.name}} "${{inputs.suffix}}" "${{inputs.macho-type}}" "${{inputs.configuration-suffix}}"
117+
env:
118+
MATRIX_SDK: ${{ matrix.sdk }}
119+
INPUT_NAME: ${{ inputs.name }}
120+
INPUT_SUFFIX: ${{ inputs.suffix }}
121+
INPUT_MACHO_TYPE: ${{ inputs.macho-type }}
122+
INPUT_CONFIG_SUFFIX: ${{ inputs.configuration-suffix }}
123+
run: ./scripts/build-xcframework-slice.sh "$MATRIX_SDK" "$INPUT_NAME" "$INPUT_SUFFIX" "$INPUT_MACHO_TYPE" "$INPUT_CONFIG_SUFFIX"
108124
shell: bash
109125

110126
# The SentrySwiftUI archive build also builds Sentry.framework as a byproduct of the dependency. We need to remove that to avoid downstream assembly tasks from tripping on these extra files. In the future we could investigate using this byproduct instead of running a separate task for Sentry.framework, or use the one already built by that other task instead of rebuilding it here.
111127
- name: Remove Sentry.framework from SentrySwiftUI build
112128
if: steps.cache-xcarchive.outputs.cache-hit != 'true' && inputs.name == 'SentrySwiftUI'
129+
env:
130+
GITHUB_WORKSPACE: ${{ github.workspace }}
113131
run: |
114-
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework" -print0 | xargs -t0 rm -rf
115-
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework.dSYM" -print0 | xargs -t0 rm -rf
132+
find "$GITHUB_WORKSPACE/Carthage/archive" -name "Sentry.framework" -print0 | xargs -t0 rm -rf
133+
find "$GITHUB_WORKSPACE/Carthage/archive" -name "Sentry.framework.dSYM" -print0 | xargs -t0 rm -rf
116134
shell: bash
117135

118136
# the upload action broke symlinks in the mac sdk slice's xcarchive
119137
- name: Zip xcarchive
120138
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
139+
env:
140+
GITHUB_WORKSPACE: ${{ github.workspace }}
141+
INPUT_NAME: ${{ inputs.name }}
142+
INPUT_SUFFIX: ${{ inputs.suffix }}
143+
MATRIX_SDK: ${{ matrix.sdk }}
121144
run: |
122-
ditto -c -k -X --rsrc --keepParent ${{github.workspace}}/Carthage/archive/${{inputs.name}}${{inputs.suffix}}/${{matrix.sdk}}.xcarchive ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip
145+
ditto -c -k -X --rsrc --keepParent ${GITHUB_WORKSPACE}/Carthage/archive/${INPUT_NAME}${INPUT_SUFFIX}/${MATRIX_SDK}.xcarchive ${INPUT_NAME}${INPUT_SUFFIX}.xcarchive.zip
123146
shell: bash
124147

125148
- name: Cache xcarchive

.github/workflows/ui-tests-common.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ jobs:
8080
XCODE_VERSION: ${{ inputs.xcode_version }}
8181
- name: Install required platforms for Xcode 26
8282
if: ${{ inputs.xcode_version == '26.0.1' }}
83-
run: ./scripts/ci-install-xOS-26-platforms.sh --platforms "${{inputs.platform}}"
83+
env:
84+
PLATFORM: ${{ inputs.platform }}
85+
run: ./scripts/ci-install-xOS-26-platforms.sh --platforms "$PLATFORM"
8486

8587
- name: Create simulator device for Xcode 26
8688
if: ${{ inputs.xcode_version == '26.0.1' }}
87-
run: ./scripts/ci-create-simulator.sh --platform "${{inputs.platform}}" --os-version "${{inputs.test-destination-os}}" --device-name "${{inputs.device}}"
89+
env:
90+
PLATFORM: ${{ inputs.platform }}
91+
OS_VERSION: ${{ inputs.test-destination-os }}
92+
DEVICE_NAME: ${{ inputs.device }}
93+
run: ./scripts/ci-create-simulator.sh --platform "$PLATFORM" --os-version "$OS_VERSION" --device-name "$DEVICE_NAME"
8894
- run: make init-ci-build
8995
if: ${{ inputs.build_with_make }}
9096

@@ -109,9 +115,11 @@ jobs:
109115
- name: Run Fastlane
110116
env:
111117
FASTLANE_COMMAND: ${{ inputs.fastlane_command }}
118+
DEVICE: ${{ inputs.device }}
119+
TEST_DESTINATION_OS: ${{ inputs.test-destination-os }}
112120
run: |
113-
if [ -n "${{inputs.device}}" ] && [ -n "${{inputs.test-destination-os}}" ]; then
114-
bundle exec fastlane "$FASTLANE_COMMAND" device:"${{inputs.device}} (${{inputs.test-destination-os}})"
121+
if [ -n "$DEVICE" ] && [ -n "$TEST_DESTINATION_OS" ]; then
122+
bundle exec fastlane "$FASTLANE_COMMAND" device:"$DEVICE ($TEST_DESTINATION_OS)"
115123
else
116124
bundle exec fastlane "$FASTLANE_COMMAND"
117125
fi

0 commit comments

Comments
 (0)