Skip to content

Automate GitHub releases for macOS builds #1

Automate GitHub releases for macOS builds

Automate GitHub releases for macOS builds #1

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release_tag:
description: "Tag to publish, for example v1.0.3"
required: true
permissions:
contents: write
concurrency:
group: release-${{ github.event_name == 'push' && github.ref_name || inputs.release_tag }}
cancel-in-progress: false
jobs:
release:
runs-on: macos-14
steps:
- name: Check Out
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve Release Tag
id: release_tag
shell: bash
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
TAG_NAME="${GITHUB_REF_NAME}"
else
TAG_NAME="${{ inputs.release_tag }}"
git fetch --tags origin
if git rev-parse "${TAG_NAME}" >/dev/null 2>&1; then
git checkout "${TAG_NAME}"
else
git tag "${TAG_NAME}" "${GITHUB_SHA}"
git push origin "${TAG_NAME}"
fi
fi
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
- name: Set Up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Resolve Swift Packages
run: |
xcodebuild \
-resolvePackageDependencies \
-project SkillsManager.xcodeproj \
-scheme SkillsManager
- name: Build Release App
env:
DERIVED_DATA: ${{ runner.temp }}/DerivedData
run: |
xcodebuild \
-project SkillsManager.xcodeproj \
-scheme SkillsManager \
-configuration Release \
-destination "platform=macOS" \
-derivedDataPath "$DERIVED_DATA" \
CODE_SIGNING_ALLOWED=NO \
build
- name: Package App
id: package
env:
DERIVED_DATA: ${{ runner.temp }}/DerivedData
TAG_NAME: ${{ steps.release_tag.outputs.tag_name }}
shell: bash
run: |
set -euo pipefail
APP_PATH="$(find "$DERIVED_DATA/Build/Products/Release" -maxdepth 1 -name 'Skills Manager.app' -print -quit)"
if [[ -z "$APP_PATH" ]]; then
echo "Release app not found" >&2
exit 1
fi
ZIP_PATH="$RUNNER_TEMP/SkillsManager-${TAG_NAME}.zip"
ditto -c -k --sequesterRsrc --keepParent "$APP_PATH" "$ZIP_PATH"
echo "app_path=$APP_PATH" >> "$GITHUB_OUTPUT"
echo "zip_path=$ZIP_PATH" >> "$GITHUB_OUTPUT"
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_tag.outputs.tag_name }}
name: Skills Manager ${{ steps.release_tag.outputs.tag_name }}
generate_release_notes: true
files: ${{ steps.package.outputs.zip_path }}