Skip to content

Nightly Build

Nightly Build #139

Workflow file for this run

name: Nightly Build
on:
workflow_dispatch: # Allows manual trigger
schedule:
- cron: '0 0 * * *'
jobs:
confirm_build:
name: Confirm Build
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if build is needed
id: should_run
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMIT="$(git rev-list --after="24 hours" ${{ github.sha }} -- '**/*.swift' | head -n 1)"
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
echo "Manual run"
echo "should_run=true" >> $GITHUB_OUTPUT
elif [[ -z "$COMMIT" ]]; then
echo "No changes"
echo "should_run=false" >> $GITHUB_OUTPUT
else
echo "Normal run"
STATUS="$(gh api -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/ecdye/macSubtitleOCR/actions/runs?branch=main&head_sha=${COMMIT}&status=completed" | \
jq -r '.workflow_runs[] | select(.name == "Test") | .conclusion')"
if [[ "$STATUS" == "success" ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
fi
nightly:
name: Nightly Build
runs-on: macos-latest
needs: confirm_build
if: ${{ needs.confirm_build.outputs.should_run != 'false' }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Import GPG key
uses: crazy-max/[email protected]
with:
gpg_private_key: "${{ secrets.RELEASE_GPG_PRIVATE_KEY }}"
passphrase: "${{ secrets.RELEASE_GPG_PASSPHRASE }}"
- name: Install FFmpeg
run: brew install ffmpeg
- name: Select Xcode
uses: mxcl/xcodebuild@v3
with:
swift: '6'
action: none
- name: Build Standalone
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sha=$(git rev-parse --short HEAD)
xcrun swift build --configuration release --arch arm64
tar -cvJf macSubtitleOCR-nightly-${sha}.tar.xz -C .build/release/ macSubtitleOCR
gpg --detach-sign --armor macSubtitleOCR-nightly-${sha}.tar.xz
gpg --verify macSubtitleOCR-nightly-${sha}.tar.xz.asc macSubtitleOCR-nightly-${sha}.tar.xz
gh release delete --yes --cleanup-tag nightly || true
- name: Build with FFmpeg
run: |
sha=$(git rev-parse --short HEAD)
USE_FFMPEG=1 xcrun swift build -Xswiftc -DFFMPEG --configuration release --arch arm64
tar -cvJf macSubtitleOCR-ffmpeg-nightly-${sha}.tar.xz -C .build/release/ macSubtitleOCR
gpg --detach-sign --armor macSubtitleOCR-ffmpeg-nightly-${sha}.tar.xz
gpg --verify macSubtitleOCR-ffmpeg-nightly-${sha}.tar.xz.asc macSubtitleOCR-ffmpeg-nightly-${sha}.tar.xz
- name: Publish
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Nightly Build
tag_name: nightly
prerelease: true
files: |
macSubtitleOCR-*.tar.xz
macSubtitleOCR-*.tar.xz.asc