ci: integrate source update into build workflow

This commit is contained in:
CelloSerenity 2026-08-27 11:38:07 -06:00
parent b916fe51cc
commit c5bad70d37
3 changed files with 56 additions and 86 deletions

22
.github/scripts/update_source.sh vendored Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
set -euo pipefail
website_directory=${1:?Usage: update_source.sh WEBSITE_DIRECTORY RELEASE_VERSION}
release_version=${2:?Usage: update_source.sh WEBSITE_DIRECTORY RELEASE_VERSION}
cd "$website_directory"
git config user.name 'GitHub Action'
git config user.email 'action@github.com'
python3 updatesource.py index.json
git add index.json
if git diff --staged --quiet; then
echo 'Website/index.json is already current.'
exit 0
fi
git commit -m "chore: update StikDebug source for $release_version"
git push origin main

View file

@ -7,12 +7,6 @@ on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
create_release:
description: Create a GitHub release from this ref
required: false
default: false
type: boolean
permissions:
contents: write
@ -21,6 +15,8 @@ jobs:
build:
name: Build IPA
runs-on: macos-latest
outputs:
version: ${{ steps.version.outputs.version }}
env:
UPLOAD_IPA: ${{ vars.UPLOAD_IPA || 'true' }}
@ -59,14 +55,14 @@ jobs:
- name: 5. Name workflow artifact
id: artifact
if: env.UPLOAD_IPA == 'true' && (github.event_name == 'push' || github.event_name == 'pull_request')
if: env.UPLOAD_IPA == 'true'
run: |
file_name="StikDebug-${GITHUB_SHA::7}.ipa"
cp StikDebug.ipa "$file_name"
echo "file_name=$file_name" >> "$GITHUB_OUTPUT"
- name: 6. Store IPA as Workflow Artifact
if: env.UPLOAD_IPA == 'true' && (github.event_name == 'push' || github.event_name == 'pull_request')
if: env.UPLOAD_IPA == 'true'
uses: actions/upload-artifact@v7
with:
path: ${{ steps.artifact.outputs.file_name }}
@ -75,7 +71,7 @@ jobs:
- name: Read version
id: version
if: startsWith(github.ref, 'refs/tags/') || inputs.create_release
if: startsWith(github.ref, 'refs/tags/')
run: |
version=$(xcodebuild -project StikDebug.xcodeproj -scheme StikDebug -showBuildSettings | awk -F ' = ' '/ MARKETING_VERSION = / { print $2; exit }')
test -n "$version"
@ -85,16 +81,42 @@ jobs:
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Name release asset
if: startsWith(github.ref, 'refs/tags/') || inputs.create_release
if: startsWith(github.ref, 'refs/tags/')
run: mv StikDebug.ipa StikDebug-${{ steps.version.outputs.version }}.ipa
- name: Publish release
if: startsWith(github.ref, 'refs/tags/') || inputs.create_release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
name: ${{ steps.version.outputs.version }}
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || steps.version.outputs.version }}
tag_name: ${{ github.ref_name }}
target_commitish: ${{ github.sha }}
files: StikDebug-${{ steps.version.outputs.version }}.ipa
generate_release_notes: true
fail_on_unmatched_files: true
update-source:
name: Update website source
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Checkout website
uses: actions/checkout@v6
with:
repository: StikDebug/Website
ref: main
path: Website
token: ${{ secrets.WEBSITE_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.x'
- name: Update StikDebug source
run: .github/scripts/update_source.sh Website '${{ needs.build.outputs.version }}'

View file

@ -1,74 +0,0 @@
name: Update StikDebug Source
on:
push:
tags: ["[0-9]*"]
permissions:
actions: read
jobs:
update-source:
runs-on: ubuntu-latest
steps:
- name: Wait for IPA build
env:
GH_TOKEN: ${{ github.token }}
run: |
endpoint="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/workflows/build_ipa.yml/runs?event=push&branch=$GITHUB_REF_NAME&head_sha=$GITHUB_SHA"
for _ in {1..120}; do
run=$(curl --fail --silent --show-error \
-H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"$endpoint" | jq '.workflow_runs[0] // empty')
status=$(jq -r '.status // empty' <<< "$run")
conclusion=$(jq -r '.conclusion // empty' <<< "$run")
if [ "$status" = "completed" ]; then
test "$conclusion" = "success"
exit 0
fi
sleep 30
done
echo "Timed out waiting for Build Debug IPA."
exit 1
- name: Checkout Website
uses: actions/checkout@v6
with:
repository: StikDebug/Website
ref: main
path: Website
token: ${{ secrets.WEBSITE_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.x'
- name: Update StikDebug source
id: update_source
working-directory: Website
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
python updatesource.py index.json
git add index.json
if git diff --staged --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected in index.json"
else
git commit -m "Update StikDebug source for latest release"
git push origin main
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Create job summary
run: |
if [[ "${{ steps.update_source.outputs.changes }}" == "true" ]]; then
echo "## StikDebug source updated" >> $GITHUB_STEP_SUMMARY
echo "Website/index.json was updated and pushed." >> $GITHUB_STEP_SUMMARY
else
echo "## StikDebug source already current" >> $GITHUB_STEP_SUMMARY
echo "No change to Website/index.json was needed." >> $GITHUB_STEP_SUMMARY
fi