Skip to content

Release Automation

Release Automation #24

Workflow file for this run

name: release macOS
on:
# workflow_run:
# workflows: [test macOS]
# types:
# - completed
workflow_dispatch:
inputs:
ref:
description: 'Ref to build (branch, tag or SHA)'
required: false
default: 'master'
pull_request:
branches:
- master
# push:
# tags:
# - '*'
jobs:
build:
name: Build Sourcery for macOS
runs-on: macos-13
steps:
- name: Set Xcode 15.1.0
run: sudo xcode-select -s /Applications/Xcode_15.1.0.app/Contents/Developer
- name: Print Current Xcode
run: xcode-select -p
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
- name: Build it
run: |
CLI_DIR="${HOME}/cli/"
RESOURCES_DIR="${CLI_DIR}Resources/"
TEMPLATES_DIR="${CLI_DIR}Templates/"
BUILD_DIR="${HOME}/build/"
BIN_DIR="${CLI_DIR}bin/"
ARTIFACT_BUNDLE_PATH="${HOME}/artifactbundle/"
path_to_sourcery_binary="${BIN_DIR}/sourcery"
mkdir -p $BIN_DIR
mkdir -p $RESOURCES_DIR
mkdir -p $TEMPLATES_DIR
mkdir -p $ARTIFACT_BUNDLE_PATH
cp -r ./Templates/Templates/* $TEMPLATES_DIR
cp ./Resources/daemon.gif $RESOURCES_DIR
cp ./Resources/icon-128.png $RESOURCES_DIR
cp ./CHANGELOG.md $CLI_DIR
cp ./README.md $CLI_DIR
cp ./LICENSE $CLI_DIR
cp -r ./docs/docsets/Sourcery.docset $CLI_DIR
cp -r ./SourceryJS/Resources/ejs.js $BIN_DIR
cp -r $CLI_DIR/* "${ARTIFACT_BUNDLE_PATH}bin"
cp ./Templates/artifactbundle.info.json.template ${ARTIFACT_BUNDLE_PATH}/info.json
swift build --disable-sandbox -c release --arch arm64 --build-path $BUILD_DIR
swift build --disable-sandbox -c release --arch x86_64 --build-path $BUILD_DIR
lipo -create -output $path_to_sourcery_binary ${BUILD_DIR}arm64-apple-macosx/release/sourcery ${BUILD_DIR}x86_64-apple-macosx/release/sourcery
strip -rSTX ${path_to_sourcery_binary}
TAG=2.1.4
FILENAME="sourcery-$TAG"
zip -r $FILENAME.zip $CLI_DIR
sed -i '' "s/VERSION/${TAG}/g" ${ARTIFACT_BUNDLE_PATH}/info.json
ARTIFACTBUNDLENAME=$FILENAME.artifactbundle
zip -r $ARTIFACTBUNDLENAME.zip $ARTIFACT_BUNDLE_PATH
- name: 'Upload Sourcery Artifact'
uses: actions/upload-artifact@v3
with:
name: $FILENAME
path: ~/$FILENAME.zip
retention-days: 5
- name: 'Upload Bundle Artifact'
uses: actions/upload-artifact@v3
with:
name: $ARTIFACTBUNDLENAME
path: ~/$ARTIFACTBUNDLENAME.zip
retention-days: 5
# # cat .github/workflows/tests.yml
# name: tests
# on: [workflow_call] # allow this workflow to be called from other workflows
# jobs:
# ...
# # cat .github/workflows/deploy.yml
# name: deploy
# on:
# push:
# tags: # trigger the deploy job on tag creation
# - *
# jobs:
# tests:
# uses: ./.github/workflows/tests.yml # use the callable tests job to run tests
# deploy:
# name: deploy
# needs: [tests] # require tests to pass before deploy runs
# ...
# The folder structure needed:
# cli/bin/
# |- sourcery
# |- ejs.js
# |- CHANGELOG.md
# |- LICENSE
# |- README.md
# |- Sourcery.docset
# |- Resources/
# |- daemon.gif
# |- icon-128.png
# |- Templates/
# |- AutoCases.stencil
# |- AutoCodable.swifttemplate
# |- AutoEquatable.stencil
# |- AutoHashable.stencil
# |- AutoLenses.stencil
# |- AutoMockable.stencil
# |- Decorator.swifttemplate
# |- LinuxMain.stencil