Skip to content

Make ad-hoc build

Make ad-hoc build #46

Workflow file for this run

name: Make ad-hoc build
on:
workflow_dispatch:
inputs:
suffix:
description: "Text to append at the end of the build name"
required: false
asana-task-url:
description: "Asana task URL"
required: false
type: string
jobs:
make-adhoc:
runs-on: macos-13
name: Make ad-hoc build
steps:
- name: Register SSH keys for access to certificates
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_FASTLANE_MATCH }}
- name: Check out the code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set cache key hash
run: |
has_only_tags=$(jq '[ .object.pins[].state | has("version") ] | all' DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved)
if [[ "$has_only_tags" == "true" ]]; then
echo "cache_key_hash=${{ hashFiles('DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}" >> $GITHUB_ENV
else
echo "Package.resolved contains dependencies specified by branch or commit, skipping cache."
fi
- name: Cache SPM
if: env.cache_key_hash
uses: actions/cache@v3
with:
path: DerivedData/SourcePackages
key: ${{ runner.os }}-spm-${{ env.cache_key_hash }}
restore-keys: |
${{ runner.os }}-spm-
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_$(<.xcode-version).app/Contents/Developer
- name: Prepare fastlane
run: bundle install
- name: Archive and upload the app
env:
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
run: |
if [[ -n "${{ github.event.inputs.suffix }}" ]]; then
bundle exec fastlane adhoc suffix:${{ github.event.inputs.suffix }}
else
bundle exec fastlane adhoc
fi
- name: Set filenames
run: |
echo "ipa_filename=${{ env.output_name }}.ipa" >> $GITHUB_ENV
echo "dsyms_filename=${{ env.output_name }}.app.dSYM.zip" >> $GITHUB_ENV
- name: Set paths
run: |
echo "ipa_path=${{ github.workspace }}/${{ env.ipa_filename }}" >> $GITHUB_ENV
echo "dsyms_path=${{ github.workspace }}/${{ env.dsyms_filename }}" >> $GITHUB_ENV
- name: Upload IPA artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ipa_filename }}
path: ${{ env.ipa_path }}
- name: Upload dSYMs artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.dsyms_filename }}
path: ${{ env.dsyms_path }}
- name: Get Asana Task ID
id: get-task-id
if: github.event.inputs.asana-task-url
run: |
task_url_regex='^https://app.asana.com/[0-9]/[0-9]*/([0-9]*)/f$'
if [[ "${{ github.event.inputs.asana-task-url }}" =~ ${task_url_regex} ]]; then
echo "task_id=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "::error::Asana Task URL has incorrect format (attempted to match ${task_url_regex})."
fi
- name: Upload IPA to Asana
if: github.event.inputs.asana-task-url
env:
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
run: |
curl -s "https://app.asana.com/api/1.0/tasks/${{ steps.get-task-id.outputs.task_id }}/attachments" \
-H "Authorization: Bearer ${{ secrets.ASANA_ACCESS_TOKEN }}" \
--form "file=@${{ env.ipa_path }};type=application/zip"