Merge pull request #45 from Rallista/feat/maven-central #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: iOS Release | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
inputs: | |
bump_version_scheme: | |
type: choice | |
description: "Release" | |
required: true | |
default: "patch" | |
options: | |
- "patch" | |
- "minor" | |
- "major" | |
jobs: | |
build: | |
runs-on: macos-14 | |
strategy: | |
matrix: | |
arch: ["arm64-ios", "arm64-ios-simulator", "x64-ios-simulator"] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-ios-build-${{ matrix.arch }} | |
cancel-in-progress: true | |
steps: | |
- name: Checkout Valhalla | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: "14.3.1" | |
- name: Setup VCPKG | |
run: | | |
git clone https://github.com/microsoft/vcpkg && git -C vcpkg checkout 2024.09.23 | |
./vcpkg/bootstrap-vcpkg.sh | |
export VCPKG_ROOT=`pwd`/vcpkg | |
- name: Build for iOS & iOS Simulator | |
run: ./build.sh --ios ${{ matrix.arch }} | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.arch }} | |
path: | | |
build/apple/${{ matrix.arch }}/install | |
create-xcframework-release: | |
needs: build | |
runs-on: macos-14 | |
steps: | |
- name: Checkout Valhalla | |
uses: actions/checkout@v4 | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: "14.3.1" | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: build/apple | |
- name: Move artifacts to correct locations | |
run: | | |
for arch in arm64-ios arm64-ios-simulator x64-ios-simulator; do | |
mkdir -p build/apple/$arch/install | |
mv build/apple/$arch/* build/apple/$arch/install/ || true | |
done | |
- name: Create XCFramework | |
run: | | |
./scripts/create_xcframework.sh | |
- name: Zip the xcframework | |
run: | | |
cd build/apple | |
zip -r valhalla-wrapper.xcframework.zip valhalla-wrapper.xcframework | |
mv valhalla-wrapper.xcframework.zip ../../ | |
cd ../../ | |
- name: Upload xcframework zip output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: valhalla-wrapper.xcframework.zip | |
path: | | |
valhalla-wrapper.xcframework.zip | |
draft-release: | |
runs-on: macos-14 | |
needs: create-xcframework-release | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
release_id: ${{ steps.release.outputs.id }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Checkout Valhalla | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT }} | |
- name: Configure Git | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
- name: Download the xcframework artifact from the build-and-test | |
uses: actions/download-artifact@v4 | |
with: | |
name: valhalla-wrapper.xcframework.zip | |
- name: Get version tag | |
id: version | |
run: ./scripts/version_bump.sh ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'patch' || inputs.bump_version_scheme }} | |
- uses: softprops/action-gh-release@v1 | |
id: release | |
with: | |
draft: true | |
generate_release_notes: true | |
tag_name: ${{ steps.version.outputs.version }} | |
files: "valhalla-wrapper.xcframework.zip" | |
- name: Write the xcframework to Package.swift | |
# run: ./scripts/write_xcframework_spm.sh ${{ fromJSON(steps.release.outputs.assets)[0].browser_download_url }} | |
run: ./scripts/write_xcframework_spm.sh ${{ steps.version.outputs.version }} | |
# https://github.com/marketplace/actions/git-auto-commit#push-to-protected-branches | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Publish Package.swift and bump version to ${{ steps.version.outputs.version }} [skip ci]" | |
tagging_message: "${{ steps.version.outputs.version }}" | |
push_options: --force | |
- name: Output version | |
run: | | |
echo "version=${{ steps.version.outputs.version }}" >> "$GITHUB_OUTPUT" | |
echo "release_id=${{ steps.release.outputs.id }}" >> "$GITHUB_OUTPUT" | |
publish-release: | |
runs-on: ubuntu-latest | |
needs: draft-release | |
steps: | |
- uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ needs.draft-release.outputs.release_id }} |