From c5bad70d37934aa84e813d5e802073d3e61ed247 Mon Sep 17 00:00:00 2001 From: CelloSerenity <195480169+CelloSerenity@users.noreply.github.com> Date: Thu, 27 Aug 2026 11:38:07 -0600 Subject: [PATCH] ci: integrate source update into build workflow --- .github/scripts/update_source.sh | 22 +++++++++ .github/workflows/build_ipa.yml | 46 ++++++++++++++----- .github/workflows/updatesource.yml | 74 ------------------------------ 3 files changed, 56 insertions(+), 86 deletions(-) create mode 100755 .github/scripts/update_source.sh delete mode 100644 .github/workflows/updatesource.yml diff --git a/.github/scripts/update_source.sh b/.github/scripts/update_source.sh new file mode 100755 index 0000000..5406385 --- /dev/null +++ b/.github/scripts/update_source.sh @@ -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 diff --git a/.github/workflows/build_ipa.yml b/.github/workflows/build_ipa.yml index 59f2d1a..e0c08bb 100644 --- a/.github/workflows/build_ipa.yml +++ b/.github/workflows/build_ipa.yml @@ -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 }}' diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml deleted file mode 100644 index 0030ed8..0000000 --- a/.github/workflows/updatesource.yml +++ /dev/null @@ -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