Skip to content

Commit e457d0f

Browse files
committed
Merge branch 'master' into support_tas_pass_key
2 parents eb025eb + e071a81 commit e457d0f

8 files changed

Lines changed: 134 additions & 70 deletions

File tree

‎.buildkite/pipeline.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
env:
2+
AWS_REGION: ap-southeast-1
3+
AWS_ROLE_ARN: arn:aws:iam::920252280240:role/S3CDNBucketUploader
4+
5+
PLUGIN_AWS_ASSUME_ROLE: "ssh://git@github.com/OmisePayments/aws-assume-role-buildkite-plugin.git#v0.2.0"
6+
7+
agents:
8+
- "queue=omise-macos-builder"
9+
10+
steps:
11+
- label: "Distribute iOS XCFrameworks"
12+
if: build.tag != null
13+
14+
plugins:
15+
- ${PLUGIN_AWS_ASSUME_ROLE}:
16+
role: ${AWS_ROLE_ARN}
17+
region: ${AWS_REGION}
18+
19+
env:
20+
AWS_DOMAIN: "https://cdn.omise.co"
21+
WRAPPER_REPO_DIR: "wrapper_repo"
22+
23+
command: |
24+
set -euo pipefail
25+
bash .buildkite/scripts/setup_and_distribute_ios.sh
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
export AWS_ROLE_ARN="arn:aws:iam::123456789012:role/example-role"
4+
export AWS_REGION="ap-southeast-1"
5+
export AWS_S3_BUCKET="sample-s3-bucket-name"
6+
export AWS_DOMAIN="https://cdn-or-s3-domain.example.com"
7+
export GIT_PAT="ghp_personal_access_token"
8+
export WRAPPER_REPO="username/wrapper-repo-name"
9+
export WRAPPER_REPO_DIR="wrapper_repo"
10+
export FLUTTER_VERSION="3.27.2"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
FLUTTER_VERSION="${FLUTTER_VERSION:-3.27.2}"
5+
FLUTTER_SDK_DIR="${HOME}/flutter_sdk_${FLUTTER_VERSION}"
6+
7+
if [[ ! -d "${FLUTTER_SDK_DIR}" ]]; then
8+
echo "📦 Installing Flutter ${FLUTTER_VERSION}…"
9+
ARCHIVE_URL="https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_${FLUTTER_VERSION}-stable.zip"
10+
curl -L -o flutter.zip "${ARCHIVE_URL}"
11+
unzip -q flutter.zip -d "${HOME}"
12+
mv "${HOME}/flutter" "${FLUTTER_SDK_DIR}"
13+
rm -f flutter.zip
14+
else
15+
echo "✅ Flutter ${FLUTTER_VERSION} already installed at ${FLUTTER_SDK_DIR}"
16+
fi
17+
18+
export PATH="${FLUTTER_SDK_DIR}/bin:${PATH}"
19+
20+
flutter precache --ios
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
export GITHUB_WORKSPACE="$(pwd)"
5+
source .buildkite/scripts/setup_env.sh
6+
7+
echo "🔍 Extracting version from pubspec.yaml…"
8+
VERSION=$(grep '^version:' pubspec.yaml | head -1 | sed 's/version: *//')
9+
export VERSION
10+
echo "📌 Using version: ${VERSION}"
11+
12+
echo "🚀 Flutter version information:"
13+
flutter --version
14+
15+
if [[ -d "${WRAPPER_REPO_DIR}" ]]; then
16+
echo "ℹ️ Removing existing ${WRAPPER_REPO_DIR} directory…"
17+
rm -rf "${WRAPPER_REPO_DIR}"
18+
fi
19+
20+
echo "🐙 Cloning Swift‑PM wrapper repository…"
21+
# Set up a temporary git credentials file to avoid exposing the token in process lists
22+
GIT_CREDENTIALS_FILE=$(mktemp)
23+
echo "https://x-access-token:${GIT_PAT}@github.com" > "$GIT_CREDENTIALS_FILE"
24+
git config --global credential.helper "store --file=$GIT_CREDENTIALS_FILE"
25+
git clone "https://github.com/${WRAPPER_REPO}.git" "${WRAPPER_REPO_DIR}"
26+
# Clean up credentials after clone
27+
git config --global --unset credential.helper
28+
rm -f "$GIT_CREDENTIALS_FILE"
29+
30+
echo "🏗️ Building and distributing XCFrameworks…"
31+
bash .buildkite/scripts/xc_release.sh
32+
33+
echo "🎉 Distribution complete"

‎.buildkite/scripts/setup_env.sh‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
LOCAL_ENV_FILE=".buildkite/scripts/env.local.sh"
6+
if [[ -f "${LOCAL_ENV_FILE}" ]]; then
7+
echo "🔧 Loading local environment overrides from ${LOCAL_ENV_FILE}"
8+
# shellcheck disable=SC1090
9+
source "${LOCAL_ENV_FILE}"
10+
fi
11+
12+
export WRAPPER_REPO_DIR="${WRAPPER_REPO_DIR:-wrapper_repo}"
13+
14+
required_vars=(
15+
AWS_S3_BUCKET
16+
AWS_REGION
17+
AWS_DOMAIN
18+
GIT_PAT
19+
WRAPPER_REPO
20+
AWS_ROLE_ARN
21+
)
22+
23+
for var in "${required_vars[@]}"; do
24+
if [[ -z "${!var:-}" ]]; then
25+
echo "❌ Environment variable ${var} is not set. Please set it in your Buildkite configuration or env.local.sh."
26+
exit 1
27+
fi
28+
done
29+
30+
echo "🧾 Environment configured!"
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ done
6868

6969
# Update SPM
7070
echo "✍️ Updating Package.swift"
71-
TEMPLATE="$GITHUB_WORKSPACE/scripts/Package.swift.template"
71+
TEMPLATE="$GITHUB_WORKSPACE/.buildkite/scripts/Package.swift.template"
7272
OUTPUT="$GITHUB_WORKSPACE/$WRAPPER_REPO_DIR/Package.swift"
7373

7474
library_targets=$(
@@ -100,6 +100,12 @@ envsubst < "$TEMPLATE" > "$OUTPUT"
100100
cd "$GITHUB_WORKSPACE/$WRAPPER_REPO_DIR"
101101
git config user.name "github-actions"
102102
git config user.email "actions@github.com"
103+
104+
# Set up git credentials for push operations
105+
GIT_CREDENTIALS_FILE=$(mktemp)
106+
echo "https://x-access-token:${GIT_PAT}@github.com" > "$GIT_CREDENTIALS_FILE"
107+
git config --global credential.helper "store --file=$GIT_CREDENTIALS_FILE"
108+
103109
git add Package.swift
104110

105111
if ! git diff --cached --quiet; then
@@ -112,12 +118,17 @@ if ! git diff --cached --quiet; then
112118
echo "🏷️ Creating GitHub Release $VERSION"
113119
# Requires GH CLI authenticated or GITHUB_TOKEN set
114120
if command -v gh >/dev/null 2>&1; then
115-
gh release create "$VERSION" \
116-
--title "v$VERSION" \
117-
--notes "Automated release for v$VERSION"
121+
export GH_TOKEN="$GIT_PAT"
122+
gh release create "$VERSION" \
123+
--title "v$VERSION" \
124+
--notes "Automated release for v$VERSION"
118125
else
119-
echo "⚠️ GitHub CLI (gh) not installed; skipping release creation"
126+
echo "⚠️ GitHub CLI (gh) not installed; skipping release creation"
120127
fi
121128
else
122129
echo "ℹ️ No changes in Package.swift; skipping commit/tag."
123130
fi
131+
132+
# Clean up credentials
133+
git config --global --unset credential.helper
134+
rm -f "$GIT_CREDENTIALS_FILE"

‎.github/workflows/publish_ios_framework.yml‎

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)