mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
- Multiple fixes and CI setup
This commit is contained in:
206
.github/workflows/nightly.yml
vendored
206
.github/workflows/nightly.yml
vendored
@@ -1,20 +1,71 @@
|
||||
name: Nightly SideStore build
|
||||
name: Nightly SideStore Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Runs every night at midnight UTC
|
||||
workflow_dispatch: # Allows manual trigger
|
||||
|
||||
# cancel duplicate run if from same branch
|
||||
concurrency:
|
||||
group: ${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check-changes:
|
||||
if: github.event_name == 'schedule'
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
has_changes: ${{ steps.check.outputs.has_changes }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Ensure full history
|
||||
|
||||
- name: Get last successful workflow run
|
||||
id: get_last_success
|
||||
run: |
|
||||
LAST_SUCCESS=$(gh run list --workflow "Nightly SideStore Build" --json createdAt,conclusion \
|
||||
--jq '[.[] | select(.conclusion=="success")][0].createdAt' || echo "")
|
||||
echo "Last successful run: $LAST_SUCCESS"
|
||||
echo "last_success=$LAST_SUCCESS" >> $GITHUB_ENV
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check for new commits since last successful build
|
||||
id: check
|
||||
run: |
|
||||
if [ -n "$LAST_SUCCESS" ]; then
|
||||
NEW_COMMITS=$(git rev-list --count --since="$LAST_SUCCESS" origin/develop)
|
||||
else
|
||||
NEW_COMMITS=1
|
||||
fi
|
||||
echo "Has changes: $NEW_COMMITS"
|
||||
if [ "$NEW_COMMITS" -gt 0 ]; then
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
LAST_SUCCESS: ${{ env.last_success }}
|
||||
|
||||
build:
|
||||
name: Build and upload SideStore Nightly releases
|
||||
needs: check-changes
|
||||
if: |
|
||||
always() &&
|
||||
(github.event_name == 'push' ||
|
||||
(github.event_name == 'schedule' && needs.check-changes.result == 'success' && needs.check-changes.outputs.has_changes == 'true'))
|
||||
concurrency:
|
||||
group: ${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
group: build-number-increment # serialize for build num cache access
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: 'macos-14'
|
||||
- os: 'macos-15'
|
||||
version: '16.1'
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -22,7 +73,6 @@ jobs:
|
||||
|
||||
- name: Set current build as BETA
|
||||
run: |
|
||||
echo "IS_BETA=1" >> $GITHUB_ENV
|
||||
echo "RELEASE_CHANNEL=beta" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout code
|
||||
@@ -36,25 +86,60 @@ jobs:
|
||||
- name: Install xcbeautify
|
||||
run: brew install xcbeautify
|
||||
|
||||
- name: Cache .nightly-build-num
|
||||
uses: actions/cache@v4
|
||||
- name: Checkout SideStore/beta-build-num
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: .nightly-build-num
|
||||
key: nightly-build-num
|
||||
repository: 'SideStore/beta-build-num'
|
||||
# ref: 'main' # use this when you want to share the build num with other beta workflows
|
||||
ref: 'nightly'
|
||||
token: ${{ secrets.CROSS_REPO_PUSH_KEY }}
|
||||
path: 'SideStore/beta-build-num'
|
||||
|
||||
- name: Get version
|
||||
id: version-marketing
|
||||
run: echo "VERSION_IPA=$(grep MARKETING_VERSION Build.xcconfig | sed -e "s/MARKETING_VERSION = //g")" >> $GITHUB_ENV
|
||||
- name: Copy build_number.txt to repo root
|
||||
run: |
|
||||
cp SideStore/beta-build-num/build_number.txt .
|
||||
|
||||
- name: Echo Build.xcconfig, build_number.txt
|
||||
run: |
|
||||
cat Build.xcconfig
|
||||
cat build_number.txt
|
||||
|
||||
- name: Increase nightly build number and set as version
|
||||
run: bash .github/workflows/increase-nightly-build-num.sh
|
||||
run: bash .github/workflows/increase-beta-build-num.sh
|
||||
|
||||
- name: Get version
|
||||
- name: Extract MARKETING_VERSION from Build.xcconfig
|
||||
id: version
|
||||
run: echo "version=$(grep MARKETING_VERSION Build.xcconfig | sed -e "s/MARKETING_VERSION = //g")" >> $GITHUB_OUTPUT
|
||||
run: |
|
||||
version=$(grep MARKETING_VERSION Build.xcconfig | sed -e 's/MARKETING_VERSION = //g')
|
||||
echo "version=$version" >> $GITHUB_OUTPUT
|
||||
echo "version=$version"
|
||||
|
||||
- name: Echo version
|
||||
run: echo "${{ steps.version.outputs.version }}"
|
||||
- name: Get short commit hash
|
||||
run: |
|
||||
# SHORT_COMMIT="${{ github.sha }}"
|
||||
SHORT_COMMIT=${GITHUB_SHA:0:7}
|
||||
echo "Short commit hash: $SHORT_COMMIT"
|
||||
echo "SHORT_COMMIT=$SHORT_COMMIT" >> $GITHUB_ENV
|
||||
|
||||
- name: Set MARKETING_VERSION
|
||||
run: |
|
||||
# Extract version number (e.g., "0.6.0")
|
||||
version=$(echo "${{ steps.version.outputs.version }}" | sed -E 's/^[^0-9]*([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
|
||||
# Extract date (YYYYMMDD) (e.g., "20250205")
|
||||
date=$(echo "${{ steps.version.outputs.version }}" | sed -E 's/.*\.([0-9]{4})\.([0-9]{2})\.([0-9]{2})\..*/\1\2\3/')
|
||||
# Extract build number (e.g., "2")
|
||||
build_num=$(echo "${{ steps.version.outputs.version }}" | sed -E 's/.*\.([0-9]+)\+.*/\1/')
|
||||
|
||||
# Combine them into the final output
|
||||
MARKETING_VERSION="${version}-${date}.${build_num}+${SHORT_COMMIT}"
|
||||
|
||||
echo "MARKETING_VERSION=$MARKETING_VERSION" >> $GITHUB_ENV
|
||||
echo "MARKETING_VERSION=$MARKETING_VERSION"
|
||||
|
||||
- name: Echo Updated Build.xcconfig, build_number.txt
|
||||
run: |
|
||||
cat Build.xcconfig
|
||||
cat build_number.txt
|
||||
|
||||
- name: Setup Xcode
|
||||
uses: maxim-lobanov/setup-xcode@v1.6.0
|
||||
@@ -203,7 +288,7 @@ jobs:
|
||||
Version: `${{ steps.version.outputs.version }}`
|
||||
|
||||
- name: Add version to IPA file name
|
||||
run: mv SideStore.ipa SideStore-${{ steps.version.outputs.version }}.ipa
|
||||
run: cp SideStore.ipa SideStore-${{ steps.version.outputs.version }}.ipa
|
||||
|
||||
- name: Upload SideStore.ipa Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -227,63 +312,68 @@ jobs:
|
||||
- name: Check if PUBLISH_BETA_UPDATES is set
|
||||
id: check_publish
|
||||
run: |
|
||||
if [[ "${{ secrets.PUBLISH_BETA_UPDATES }}" != "__YES__" ]]; then
|
||||
echo "PUBLISH_BETA_UPDATES=${{ vars.PUBLISH_BETA_UPDATES }}"
|
||||
if [[ "${{ vars.PUBLISH_BETA_UPDATES }}" == "__YES__" ]]; then
|
||||
echo "PUBLISH_BETA_UPDATES is not set. Skipping deployment."
|
||||
exit 1 # Exit with 1 to indicate no deployment
|
||||
echo "should_deploy=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "PUBLISH_BETA_UPDATES is set. Proceeding with deployment."
|
||||
exit 0 # Exit with 0 to indicate deployment should proceed
|
||||
echo "should_deploy=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
continue-on-error: true # Continue even if exit code is 1
|
||||
|
||||
- name: Get short commit hash
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
run: |
|
||||
# SHORT_COMMIT="${{ github.sha }}"
|
||||
SHORT_COMMIT=${GITHUB_SHA:0:7}
|
||||
echo "Short commit hash: $SHORT_COMMIT"
|
||||
echo "SHORT_COMMIT=$SHORT_COMMIT" >> $GITHUB_ENV
|
||||
|
||||
- name: Get formatted date
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
if: steps.check_publish.outputs.should_deploy == 'true'
|
||||
run: |
|
||||
FORMATTED_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
echo "Formatted date: $FORMATTED_DATE"
|
||||
echo "FORMATTED_DATE=$FORMATTED_DATE" >> $GITHUB_ENV
|
||||
|
||||
- name: Get size of IPA in bytes (macOS/Linux)
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
if: steps.check_publish.outputs.should_deploy == 'true'
|
||||
run: |
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
# macOS
|
||||
IPA_SIZE=$(stat -f %z SideStore-${{ steps.version.outputs.version }}.ipa)
|
||||
IPA_SIZE=$(stat -f %z SideStore.ipa)
|
||||
else
|
||||
# Linux
|
||||
IPA_SIZE=$(stat -c %s SideStore-${{ steps.version.outputs.version }}.ipa)
|
||||
IPA_SIZE=$(stat -c %s SideStore.ipa)
|
||||
fi
|
||||
echo "IPA size in bytes: $IPA_SIZE"
|
||||
echo "IPA_SIZE=$IPA_SIZE" >> $GITHUB_ENV
|
||||
|
||||
- name: Compute SHA-256 of IPA
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
if: steps.check_publish.outputs.should_deploy == 'true'
|
||||
run: |
|
||||
SHA256_HASH=$(shasum -a 256 SideStore-${{ steps.version.outputs.version }}.ipa | awk '{ print $1 }')
|
||||
SHA256_HASH=$(shasum -a 256 SideStore.ipa | awk '{ print $1 }')
|
||||
echo "SHA-256 Hash: $SHA256_HASH"
|
||||
echo "SHA256_HASH=$SHA256_HASH" >> $GITHUB_ENV
|
||||
|
||||
- name: Set environment variables dynamically
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
if: steps.check_publish.outputs.should_deploy == 'true'
|
||||
run: |
|
||||
echo "VERSION_IPA=$VERSION_IPA" >> $GITHUB_ENV
|
||||
|
||||
LOCALIZED_DESCRIPTION=$(cat <<EOF
|
||||
This is release for:
|
||||
- version: "${{ steps.version.outputs.version }}"
|
||||
- revision: "$SHORT_COMMIT"
|
||||
- track: "$RELEASE_CHANNEL"
|
||||
- timestamp: "${{ steps.date.outputs.date }}"
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "VERSION_IPA=$MARKETING_VERSION" >> $GITHUB_ENV
|
||||
echo "VERSION_DATE=$FORMATTED_DATE" >> $GITHUB_ENV
|
||||
echo "COMMIT_ID=$SHORT_COMMIT" >> $GITHUB_ENV
|
||||
echo "SIZE=$IPA_SIZE" >> $GITHUB_ENV
|
||||
echo "SHA256=$SHA256_HASH" >> $GITHUB_ENV
|
||||
echo "LOCALIZED_DESCRIPTION=This is nightly release for revision: ${{ github.sha }}" >> $GITHUB_ENV
|
||||
echo "DOWNLOAD_URL=https://github.com/SideStore/SideStore/releases/download/nightly/SideStore.ipa" >> $GITHUB_ENV
|
||||
|
||||
# multiline strings
|
||||
echo "LOCALIZED_DESCRIPTION<<EOF" >> $GITHUB_ENV
|
||||
echo "$LOCALIZED_DESCRIPTION" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout SideStore/apps-v2.json
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
if: steps.check_publish.outputs.should_deploy == 'true'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Repository name with owner. For example, actions/checkout
|
||||
@@ -292,11 +382,11 @@ jobs:
|
||||
ref: 'main' # TODO: use branches for alpha and beta tracks? so as to avoid push collision?
|
||||
# ref: 'nightly' # TODO: use branches for alpha and beta tracks? so as to avoid push collision?
|
||||
# token: ${{ github.token }}
|
||||
token: ${{ secrets.APPS_DEPLOY_KEY }}
|
||||
token: ${{ secrets.CROSS_REPO_PUSH_KEY }}
|
||||
path: 'SideStore/apps-v2.json'
|
||||
|
||||
- name: Publish to SideStore/apps-v2.json
|
||||
if: ${{ steps.check_publish.outcome == 'success' }}
|
||||
id: publish-release
|
||||
run: |
|
||||
# Copy and execute the update script
|
||||
pushd SideStore/apps-v2.json/
|
||||
@@ -312,6 +402,32 @@ jobs:
|
||||
git add ./_includes/source.json
|
||||
git commit -m " - updated for $SHORT_COMMIT deployment" || echo "No changes to commit"
|
||||
|
||||
git status
|
||||
git push origin HEAD:main
|
||||
git push --verbose
|
||||
popd
|
||||
|
||||
- name: Echo Updated Build.xcconfig, build_number.txt
|
||||
run: |
|
||||
cat Build.xcconfig
|
||||
cat build_number.txt
|
||||
|
||||
# save it
|
||||
- name: Publish to SideStore/beta-build-num
|
||||
run: |
|
||||
rm SideStore/beta-build-num/build_number.txt
|
||||
mv build_number.txt SideStore/beta-build-num/build_number.txt
|
||||
pushd SideStore/beta-build-num/
|
||||
|
||||
echo "Configure Git user (committer details)"
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
|
||||
echo "Adding files to commit"
|
||||
git add --verbose build_number.txt
|
||||
git commit -m " - updated for $RELEASE_CHANNEL - $SHORT_COMMIT deployment" || echo "No changes to commit"
|
||||
|
||||
echo "Performing git pull, to see if any extenal change has been made within our current run duration"
|
||||
git pull
|
||||
|
||||
echo "Pushing to remote repo"
|
||||
git push --verbose
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user