Skip to content

Publish iOS

Publish iOS #30

Workflow file for this run

name: Publish iOS
defaults:
run:
shell: bash -ieo pipefail {0}
on:
workflow_dispatch:
inputs:
version:
description: 'Version (enter prefix v, like v0.0.1)'
required: true
type: string
permissions:
contents: write
packages: write
jobs:
publish:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 11
cache: 'gradle'
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14.0'
- name: Cache Konan
id: cache-konan
uses: actions/cache@v3
with:
path: ~/.konan/
key: konan
- name: Install brew
run: brew install hub
- uses: burrunan/gradle-cache-action@v1
name: Build XCFramework
env:
JAVA_HOME: ${{ env.JAVA_HOME_11 }}
with:
job-id: publish-ci
concurrent: true
arguments: :assembleAuthlibReleaseXCFramework
- name: Prepare ZIP
run: |
set -x
RELEASE_DIR="${{ github.workspace }}/build/XCFrameworks/release/"
function zipXCFramework {
cd $1
zip -r $2.xcframework.zip $2.xcframework/*
cd -
}
zipXCFramework ${{ github.workspace }}/build/XCFrameworks/release/ authlib
function replaceChecksum {
CHECKSUM=$(swift package compute-checksum "$RELEASE_DIR$1".xcframework.zip)
sed -i '' "s/checksum: \"[a-z0-9]*\"\/\/ $1 Checksum/checksum: \"$CHECKSUM\"\/\/ $1 Checksum/g" Package.swift
}
function replaceURL {
BASE_URL="https:\/\/github.com\/HedvigInsurance\/authlib\/releases\/download\/$1"
sed -i '' "s/url: \".*\",\/\/ $2 URL/url: \"$BASE_URL\/$2.xcframework.zip\",\/\/ $2 URL/g" Package.swift
}
replaceChecksum "authlib"
replaceURL "${{ inputs.version }}" "authlib"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Package.swift
uses: test-room-7/action-update-file@v1
with:
file-path: Package.swift
commit-msg: Update Package.swift
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Make release
run: |
set -x
for asset in ${{ github.workspace }}/build/XCFrameworks/release/*.zip; do
assets+=("-a" "$asset")
done
hub release create "${assets[@]}" -m "${{ inputs.version }}" "${{ inputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}