Skip to content

Commit 7150a37

Browse files
authored
ci: set-output is deprecated (#1164)
More information here: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ Also took the opportunity to update the `rnx-build.yml` workflow from rnx-kit.
1 parent b8e1f61 commit 7150a37

File tree

7 files changed

+63
-86
lines changed

7 files changed

+63
-86
lines changed

.github/actions/cocoapods/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ runs:
1414
id: cache-key-generator
1515
run: |
1616
if [[ -f ${{ inputs.working-directory }}/${{ inputs.project-directory }}/Podfile.lock ]]; then
17-
echo "::set-output name=cache-key::$(node scripts/shasum.mjs ${{ inputs.working-directory }}/${{ inputs.project-directory }}/Podfile.lock)"
17+
echo "cache-key=$(node scripts/shasum.mjs ${{ inputs.working-directory }}/${{ inputs.project-directory }}/Podfile.lock)" >> $GITHUB_OUTPUT
1818
else
19-
echo '::set-output name=cache-key::false'
19+
echo 'cache-key=false' >> $GITHUB_OUTPUT
2020
fi
2121
shell: bash
2222
- name: Cache /${{ inputs.working-directory }}/${{ inputs.project-directory }}/Pods

.github/actions/gradle/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ runs:
1414
id: build-root-directory-finder
1515
run: |
1616
if [[ -f android/build.gradle ]]; then
17-
echo "::set-output name=build-root-directory::${{ inputs.project-root }}/android"
17+
echo "build-root-directory=${{ inputs.project-root }}/android" >> $GITHUB_OUTPUT
1818
else
19-
echo "::set-output name=build-root-directory::${{ inputs.project-root }}"
19+
echo "build-root-directory=${{ inputs.project-root }}" >> $GITHUB_OUTPUT
2020
fi
2121
shell: bash
2222
working-directory: ${{ inputs.project-root }}

.github/actions/init-test-app/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
steps:
1010
- name: Generate cache key
1111
id: cache-key-generator
12-
run: echo "::set-output name=cache-key::$(node scripts/shasum.mjs yarn.lock)"
12+
run: echo "cache-key=$(node scripts/shasum.mjs yarn.lock)" >> $GITHUB_OUTPUT
1313
shell: bash
1414
- name: Cache /.yarn/cache
1515
uses: actions/cache@v3

.github/actions/setup-toolchain/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ runs:
5252
id: cache-key-generator
5353
run: |
5454
if [[ -f example/${{ inputs.platform }}/Podfile.lock ]]; then
55-
echo "::set-output name=cache-key::$(node scripts/shasum.mjs example/${{ inputs.platform }}/Podfile.lock)"
55+
echo "cache-key=$(node scripts/shasum.mjs example/${{ inputs.platform }}/Podfile.lock)" >> $GITHUB_OUTPUT
5656
else
57-
echo '::set-output name=cache-key::false'
57+
echo 'cache-key=false' >> $GITHUB_OUTPUT
5858
fi
5959
shell: bash
6060
- name: Cache /.ccache

.github/actions/yarn/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
steps:
1010
- name: Generate cache key
1111
id: cache-key-generator
12-
run: echo "::set-output name=cache-key::$(node scripts/shasum.mjs yarn.lock)"
12+
run: echo "cache-key=$(node scripts/shasum.mjs yarn.lock)" >> $GITHUB_OUTPUT
1313
shell: bash
1414
- name: Cache /.yarn/cache
1515
uses: actions/cache@v3

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ jobs:
197197
id: configure
198198
run: |
199199
if [[ ${{ matrix.template }} == ios ]]; then
200-
echo '::set-output name=project-directory::.'
200+
echo 'project-directory=.' >> $GITHUB_OUTPUT
201201
else
202-
echo '::set-output name=project-directory::ios'
202+
echo 'project-directory=ios' >> $GITHUB_OUTPUT
203203
fi
204204
- name: Install Pods
205205
run: |
@@ -361,9 +361,9 @@ jobs:
361361
id: configure
362362
run: |
363363
if [[ ${{ matrix.template }} == macos ]]; then
364-
echo '::set-output name=project-directory::.'
364+
echo 'project-directory=.' >> $GITHUB_OUTPUT
365365
else
366-
echo '::set-output name=project-directory::macos'
366+
echo 'project-directory=macos' >> $GITHUB_OUTPUT
367367
fi
368368
- name: Install Pods
369369
run: |

.github/workflows/rnx-build.yml

Lines changed: 51 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
description: "Supported device types are `device`, `emulator`, `simulator`"
1111
required: true
1212
default: "simulator"
13+
distribution:
14+
description: "Distribution config string, e.g. `local` or `firebase:<appId>`"
15+
required: true
16+
default: "local"
1317
packageManager:
1418
description: "Binary name of the package manager used in the current repo"
1519
required: true
@@ -54,6 +58,7 @@ jobs:
5458
name: android-artifact
5559
path: ${{ github.event.inputs.projectRoot }}/android/app/build/outputs/apk/debug/app-debug.apk
5660
if-no-files-found: error
61+
retention-days: 14
5762
build-ios:
5863
name: "Build iOS"
5964
if: ${{ github.event.inputs.platform == 'ios' }}
@@ -62,6 +67,7 @@ jobs:
6267
CERTIFICATE_FILE: build-certificate.p12
6368
KEYCHAIN_FILE: app-signing.keychain-db
6469
PROVISION_PATH: "Library/MobileDevice/Provisioning Profiles/Provisioning_Profile.mobileprovision"
70+
XCARCHIVE_FILE: app.xcarchive
6571
steps:
6672
- name: Checkout
6773
uses: actions/checkout@v3
@@ -72,19 +78,7 @@ jobs:
7278
- name: Install npm dependencies
7379
run: ${{ github.event.inputs.packageManager }} install
7480
- name: Install Pods
75-
run: pod install --project-directory=ios
76-
working-directory: ${{ github.event.inputs.projectRoot }}
77-
- name: Disable Clang sanitizers
78-
run: |
79-
# We need to disable Clang sanitizers otherwise the app will crash on
80-
# startup trying to load Clang sanitizer libraries that would only
81-
# exist if Xcode was attached.
82-
xcconfig=node_modules/.generated/ios/ReactTestApp/ReactTestApp.debug.xcconfig
83-
if [[ -f "${xcconfig}" ]]; then
84-
sed -i '' 's/CLANG_ADDRESS_SANITIZER = YES/CLANG_ADDRESS_SANITIZER = NO/g' "${xcconfig}"
85-
sed -i '' 's/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = YES/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = NO/g' "${xcconfig}"
86-
sed -i '' 's/-fsanitize=bounds//g' "${xcconfig}"
87-
fi
81+
run: pod install --project-directory=ios --verbose
8882
working-directory: ${{ github.event.inputs.projectRoot }}
8983
- name: Install Apple signing certificate and provisioning profile
9084
if: ${{ github.event.inputs.deviceType == 'device' }}
@@ -93,56 +87,35 @@ jobs:
9387
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
9488
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
9589
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
96-
run: |
97-
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
98-
mkdir -p "$(dirname "${HOME}/${PROVISION_PATH}")"
99-
100-
echo -n "${BUILD_CERTIFICATE_BASE64}" | base64 --decode --output "${RUNNER_TEMP}/${CERTIFICATE_FILE}"
101-
echo -n "${BUILD_PROVISION_PROFILE_BASE64}" | base64 --decode --output "${HOME}/${PROVISION_PATH}"
102-
103-
security create-keychain -p "${KEYCHAIN_PASSWORD}" "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
104-
security set-keychain-settings -lut 21600 "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
105-
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
106-
107-
security import "${RUNNER_TEMP}/${CERTIFICATE_FILE}" -k "${RUNNER_TEMP}/${KEYCHAIN_FILE}" -t cert -f pkcs12 -P "${P12_PASSWORD}" -A -T '/usr/bin/codesign' -T '/usr/bin/security'
108-
security set-key-partition-list -S apple-tool:,apple: -k ${KEYCHAIN_PASSWORD} "${RUNNER_TEMP}/${KEYCHAIN_FILE}" 1> /dev/null
109-
security list-keychain -d user -s "${RUNNER_TEMP}/${KEYCHAIN_FILE}" login.keychain
90+
run: npx --prefix . rnx-build-apple install-certificate
11091
- name: Build iOS app
111-
run: |
112-
if [[ ${{ github.event.inputs.deviceType }} == 'device' ]]; then
113-
destination='generic/platform=iOS'
114-
code_signing=''
115-
else
116-
destination='generic/platform=iOS Simulator'
117-
code_signing='CODE_SIGNING_ALLOWED=NO'
118-
fi
119-
xcworkspace=$(find . -maxdepth 1 -name '*.xcworkspace' -type d | head -1)
120-
xcodebuild -workspace ${xcworkspace} -scheme ${{ github.event.inputs.scheme }} -destination "${destination}" -configuration Debug -derivedDataPath DerivedData ${code_signing} COMPILER_INDEX_STORE_ENABLE=NO build
92+
run: npx --prefix . rnx-build-apple build-ios --scheme ${{ github.event.inputs.scheme }} --device-type ${{ github.event.inputs.deviceType }} --archs ${{ github.event.inputs.architecture }}
12193
working-directory: ${{ github.event.inputs.projectRoot }}/ios
12294
- name: Remove Apple signing certificate and provisioning profile
95+
# Always run this job step, even if previous ones fail. See also
96+
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#required-clean-up-on-self-hosted-runners
12397
if: ${{ always() && github.event.inputs.deviceType == 'device' }}
124-
run: |
125-
# Always run this job step, even if previous ones fail. See also
126-
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#required-clean-up-on-self-hosted-runners
127-
security delete-keychain "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
128-
rm -f "${RUNNER_TEMP}/${CERTIFICATE_FILE}" "${HOME}/${PROVISION_PATH}"
98+
run: npx --prefix . rnx-build-apple uninstall-certificate
12999
- name: Prepare build artifact
100+
id: prepare-build-artifact
130101
run: |
131-
output_path=DerivedData/Build/Products
132-
app=$(find ${output_path} -maxdepth 2 -name '*.app' -type d | head -1)
133-
# bsdtar corrupts files when archiving due to APFS sparse files. A
134-
# workaround is to use GNU Tar instead. See also:
135-
# - https://github.com/actions/cache/issues/403
136-
# - https://github.com/actions/virtual-environments/issues/2619
137-
gtar -cvf ios-artifact.tar -C "$(dirname ${app})" "$(basename ${app})"
138-
shasum --algorithm 256 ios-artifact.tar
102+
if [[ ${{ github.event.inputs.distribution }} == 'local' ]]; then
103+
app=$(find ${XCARCHIVE_FILE}/Products/Applications -maxdepth 1 -name '*.app' -type d | head -1)
104+
npx --prefix . rnx-build-apple archive ios-artifact.tar "${app}"
105+
echo 'filename=ios-artifact.tar' >> $GITHUB_OUTPUT
106+
else
107+
xcodebuild -exportArchive -archivePath ${XCARCHIVE_FILE} -exportPath export -exportOptionsPlist ExportOptions.plist 2>&1
108+
ipa=$(find export -maxdepth 1 -name '*.ipa' -type d | head -1)
109+
echo "filename=${ipa}" >> $GITHUB_OUTPUT
110+
fi
139111
working-directory: ${{ github.event.inputs.projectRoot }}/ios
140112
- name: Upload build artifact
141113
uses: actions/upload-artifact@v3
142114
with:
143115
name: ios-artifact
144-
path: ${{ github.event.inputs.projectRoot }}/ios/ios-artifact.tar
116+
path: ${{ github.event.inputs.projectRoot }}/ios/${{ steps.prepare-build-artifact.outputs.filename }}
145117
if-no-files-found: error
118+
retention-days: 14
146119
build-macos:
147120
name: "Build macOS"
148121
if: ${{ github.event.inputs.platform == 'macos' }}
@@ -157,42 +130,24 @@ jobs:
157130
- name: Install npm dependencies
158131
run: ${{ github.event.inputs.packageManager }} install
159132
- name: Install Pods
160-
run: pod install --project-directory=macos
161-
working-directory: ${{ github.event.inputs.projectRoot }}
162-
- name: Disable Clang sanitizers
163-
run: |
164-
# We need to disable Clang sanitizers otherwise the app will crash on
165-
# startup trying to load Clang sanitizer libraries that would only
166-
# exist if Xcode was attached.
167-
xcconfig=node_modules/.generated/macos/ReactTestApp/ReactTestApp.debug.xcconfig
168-
if [[ -f "${xcconfig}" ]]; then
169-
sed -i '' 's/CLANG_ADDRESS_SANITIZER = YES/CLANG_ADDRESS_SANITIZER = NO/g' "${xcconfig}"
170-
sed -i '' 's/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = YES/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = NO/g' "${xcconfig}"
171-
sed -i '' 's/-fsanitize=bounds//g' "${xcconfig}"
172-
fi
133+
run: pod install --project-directory=macos --verbose
173134
working-directory: ${{ github.event.inputs.projectRoot }}
174135
- name: Build macOS app
175-
run: |
176-
xcworkspace=$(find . -maxdepth 1 -name '*.xcworkspace' -type d | head -1)
177-
xcodebuild -workspace ${xcworkspace} -scheme ${{ github.event.inputs.scheme }} -configuration Debug -derivedDataPath DerivedData CODE_SIGNING_ALLOWED=NO COMPILER_INDEX_STORE_ENABLE=NO build
136+
run: npx --prefix . rnx-build-apple build-macos --scheme ${{ github.event.inputs.scheme }}
178137
working-directory: ${{ github.event.inputs.projectRoot }}/macos
179138
- name: Prepare build artifact
180139
run: |
181140
output_path=DerivedData/Build/Products
182141
app=$(find ${output_path} -maxdepth 2 -name '*.app' -type d | head -1)
183-
# bsdtar corrupts files when archiving due to APFS sparse files. A
184-
# workaround is to use GNU Tar instead. See also:
185-
# - https://github.com/actions/cache/issues/403
186-
# - https://github.com/actions/virtual-environments/issues/2619
187-
gtar -cvf macos-artifact.tar -C "$(dirname ${app})" "$(basename ${app})"
188-
shasum --algorithm 256 macos-artifact.tar
142+
npx --prefix . rnx-build-apple archive macos-artifact.tar "${app}"
189143
working-directory: ${{ github.event.inputs.projectRoot }}/macos
190144
- name: Upload build artifact
191145
uses: actions/upload-artifact@v3
192146
with:
193147
name: macos-artifact
194148
path: ${{ github.event.inputs.projectRoot }}/macos/macos-artifact.tar
195149
if-no-files-found: error
150+
retention-days: 14
196151
build-windows:
197152
name: "Build Windows"
198153
if: ${{ github.event.inputs.platform == 'windows' }}
@@ -226,7 +181,7 @@ jobs:
226181
appx_manifest=$(find ${{ github.event.inputs.architecture }}/Debug -name AppxManifest.xml -type f | head -1)
227182
app_name=$(basename $(dirname ${appx_manifest}))
228183
cp ${appx_manifest} AppPackages/${app_name}/*
229-
echo "::set-output name=app-name::${app_name}"
184+
echo "app-name=${app_name}" >> $GITHUB_OUTPUT
230185
shell: bash
231186
working-directory: ${{ github.event.inputs.projectRoot }}/windows
232187
- name: Upload build artifact
@@ -235,3 +190,25 @@ jobs:
235190
name: windows-artifact
236191
path: ${{ github.event.inputs.projectRoot }}/windows/AppPackages/${{ steps.prepare-build-artifact.outputs.app-name }}
237192
if-no-files-found: error
193+
retention-days: 14
194+
distribute:
195+
name: "Distribute build"
196+
needs: [build-android, build-ios]
197+
runs-on: ubuntu-20.04
198+
if: ${{ github.event.inputs.distribution != 'local' && !cancelled() && !failure() }} # `success()` excludes skipped jobs
199+
steps:
200+
- name: Download build artifact
201+
uses: actions/download-artifact@v3
202+
with:
203+
name: ${{ github.event.inputs.platform }}-artifact
204+
- name: Display structure of build artifact
205+
run: ls -R
206+
- name: Upload to Firebase
207+
if: ${{ startsWith(github.event.inputs.distribution, 'firebase:') }}
208+
env:
209+
FIREBASE_APP_ID: ${{ github.event.inputs.distribution }}
210+
GOOGLE_APPLICATION_CREDENTIALS: credentials.json
211+
run: |
212+
artifact=$(find . -maxdepth 1 -type f | head -1)
213+
echo -n "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}" | base64 --decode > ${GOOGLE_APPLICATION_CREDENTIALS}
214+
npx --package firebase-tools@11 firebase appdistribution:distribute "${artifact}" --app ${FIREBASE_APP_ID:9} --release-notes "${{ github.ref_name }}"

0 commit comments

Comments
 (0)