Build and Release App #45
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: Build and Release App | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'README.md' | |
- '**.github/workflows/*' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
release: | |
runs-on: macos-13 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Certificate | |
uses: apple-actions/import-codesign-certs@v2 | |
with: | |
p12-file-base64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | |
p12-password: ${{ secrets.P12_PASSWORD }} | |
- name: Xcode Select Version | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: '15.0.1' | |
- name: Get Next Version | |
id: semver | |
uses: ietf-tools/semver-action@v1 | |
with: | |
skipInvalidTags: true | |
noVersionBumpBehavior: "error" | |
majorList: "major, breaking" | |
token: ${{ env.GITHUB_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Bump version in Config.xcconfig | |
run: | | |
CURRENT_BUILD=$(grep BUILD_NUMBER ishare/Config.xcconfig | cut -d ' ' -f 3) | |
NEW_BUILD=$((CURRENT_BUILD + 1)) | |
sed -i '' "s/BUILD_NUMBER = $CURRENT_BUILD/BUILD_NUMBER = $NEW_BUILD/" ishare/Config.xcconfig | |
CURRENT_VERSION=$(grep VERSION ishare/Config.xcconfig | cut -d ' ' -f 3) | |
NEW_VERSION=${{ steps.semver.outputs.nextStrict }} | |
sed -i '' "s/VERSION = $CURRENT_VERSION/VERSION = $NEW_VERSION/" ishare/Config.xcconfig | |
- name: Build Changelog | |
uses: dlavrenuek/[email protected] | |
id: changelog | |
with: | |
from: ${{ steps.semver.outputs.current }} | |
to: HEAD | |
- name: Build macOS app | |
run: xcodebuild archive -scheme "ishare" -configuration "Release" -archivePath "build/ishare.xcarchive" -destination "platform=macOS" | |
- name: Commit & Push changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: 'ishare/Config.xcconfig' | |
default_author: github_actions | |
fetch: false | |
message: 'Bump version [skip ci]' | |
push: true | |
- name: Export .app from .xcarchive | |
run: cp -R "build/ishare.xcarchive/Products/Applications/ishare.app" "build/" | |
- name: Archive .app | |
run: cd build && zip -r "ishare_macOS.zip" "ishare.app" | |
- name: Download Sparkle | |
run: | | |
curl -L -o Sparkle-2.4.2.tar.xz https://github.com/sparkle-project/Sparkle/releases/download/2.4.2/Sparkle-2.4.2.tar.xz | |
- name: Extract Sparkle | |
run: tar -xJf Sparkle-2.4.2.tar.xz | |
- name: Prepare update folder | |
run: | | |
mkdir update | |
mv ./build/ishare_macOS.zip update/ | |
echo "${{ steps.changelog.outputs.body }}" > RELEASE.md | |
- name: Convert Markdown to HTML | |
uses: jaywcjlove/markdown-to-html-cli@main | |
with: | |
source: RELEASE.md | |
output: ./update/ishare_macOS.html | |
corners: false | |
- name: Set executable bit for generate_appcast | |
run: chmod +x ./bin/generate_appcast | |
- name: Generate appcast.xml | |
run: echo "$EDDSA_PRIVATE_KEY" | ./bin/generate_appcast --ed-key-file - --link https://isharemac.app --embed-release-notes --download-url-prefix https://github.com/castdrian/ishare/releases/latest/download/ update/ | |
env: | |
EDDSA_PRIVATE_KEY: ${{ secrets.EDDSA_PRIVATE_KEY }} | |
ARCHIVES_SOURCE_DIR: . | |
- name: Archive appcast.xml as artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: appcast | |
path: ./update/appcast.xml | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.semver.outputs.next }} | |
body_path: RELEASE.md | |
files: ./update/ishare_macOS.zip | |
fail_on_unmatched_files: true | |
token: ${{ env.GITHUB_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
pages: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download appcast.xml artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: appcast | |
path: ./ | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Build with Jekyll | |
uses: actions/jekyll-build-pages@v1 | |
with: | |
source: ./ | |
destination: ./_site | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |